Multiplication Table
CF#256D:http://codeforces.com/contest/448/problem/D
题意:给你一个n*m的表格,第i行第j列的数据是i*j,然后询问第k小的数,这里的排序是不去重的。
题解:二分,每次判断当前的数是第几大,然后与k进行比较。这里统计这个数是第几大,要for一遍,一开始不知道怎么统计,看了别人的知道自己傻了。这里二分的时候不用判断这个数是否在这个表中,为什么不用,自己要好好体会。
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
using namespace std;
long long n,m;
long long k;
bool judge(long long x){
long long ans=,tmp;
for(long long i=;i<=n;i++){
tmp=min(i*m,x);
ans+=tmp/i;
}
return ans<k;
}
int main(){
while(~scanf("%I64d%I64d%I64d",&n,&m,&k)){
long long l=,r=n*m;
while(l<r){
long long mid=(l+r)/;
if(judge(mid))l=mid+;
else r=mid;
}
printf("%I64d\n",r);
}
}
Multiplication Table的更多相关文章
- hdu4951 Multiplication table (乘法表的奥秘)
http://acm.hdu.edu.cn/showproblem.php?pid=4951 2014多校 第八题 1008 2014 Multi-University Training Contes ...
- Codeforces Codeforces Round #319 (Div. 2) A. Multiplication Table 水题
A. Multiplication Table Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/57 ...
- cf448D Multiplication Table
D. Multiplication Table time limit per test 1 second memory limit per test 256 megabytes input stand ...
- Codeforces Round #256 (Div. 2) D. Multiplication Table(二进制搜索)
转载请注明出处:viewmode=contents" target="_blank">http://blog.csdn.net/u012860063?viewmod ...
- Codeforces Round #256 (Div. 2) D. Multiplication Table 二分法
D. Multiplication Table time limit per test 1 second memory limit per test 256 megabytes input st ...
- Codeforces 448 D. Multiplication Table
二分法判断答案 D. Multiplication Table time limit per test 1 second memory limit per test 256 megabytes inp ...
- Codeforces 448 D. Multiplication Table 二分
题目链接:D. Multiplication Table 题意: 给出N×M的乘法矩阵要你求在这个惩罚矩阵中第k个小的元素(1 ≤ n, m ≤ 5·10^5; 1 ≤ k ≤ n·m). 题解: n ...
- [LeetCode] Kth Smallest Number in Multiplication Table 乘法表中的第K小的数字
Nearly every one have used the Multiplication Table. But could you find out the k-th smallest number ...
- [Swift]LeetCode668. 乘法表中第k小的数 | Kth Smallest Number in Multiplication Table
Nearly every one have used the Multiplication Table. But could you find out the k-th smallest number ...
- Codeforces Round #256 (Div. 2) D. Multiplication Table 很有想法的一个二分
D. Multiplication Table time limit per test 1 second memory limit per test 256 megabytes input stand ...
随机推荐
- mac上charels抓包工具使用技巧
有这俩技巧就足够了 http://www.jianshu.com/p/18449f5f9d1c http://blog.csdn.net/u010187139/article/details/5198 ...
- python字符串连接的三种方法及其效率、适用场景详解
python字符串连接的方法,一般有以下三种:方法1:直接通过加号(+)操作符连接website=& 39;python& 39;+& 39;tab& 39;+& ...
- android scrollview组件禁止滑动的方法
xml配置: android:id="@+id/sc_freement" android:layout_width="fill ...
- SpringMVC 学习笔记(一) Hello World
springMVC概述: Spring MVC 是眼下最主流的MVC 框架之中的一个 Spring MVC 通过一套 MVC 注解.让 POJO 成为处理请 求的控制器,而无须实现不论什么接口. 支持 ...
- 查看linux系统状态
就类似你装完xp后,或者你拿到一台新的机器的时候,你通常都是进入系统,看看他的cpu,内存,硬盘使用情况.我也按照这个来看看linux的系统状态.1:top 退出按q,这个就类似windows的任务管 ...
- TCP/IP协议原理与应用笔记07:HTTP、TCP/IP与socket区别
1. TCP/IP协议与HTTP协议区别: HTTP 超文本传输协议(HTTP,HyperText Transfer Protocol)是互联网上应用最为广泛的一种网络协议.所有的WWW文件 ...
- 成为VR开发者的六个基本问题
2016-05-31 小小CTO 未来CTO 我常被问起能否提供更多的建议,帮助其他人进入这个行业,或是做VR开发人员该怎么赚钱.我很难具体回答,因为每个人的情况都很不一样.不过还是有一些建议适用于想 ...
- haproxy主配置文件
1.haproxy 配置文件 ------------------------------------------------------------------------------------- ...
- 正则表达式匹配(python)
获取图片的python代码 #coding=utf-8 import urllib import re def getHtml(url): page = urllib.urlopen(url) htm ...
- asp.net web.config的学习笔记
原文地址:http://www.cnblogs.com/Bulid-For-NET/archive/2013/01/11/2856632.html 一直都对web.config不太清楚.这几天趁着项目 ...