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的更多相关文章

  1. hdu4951 Multiplication table (乘法表的奥秘)

    http://acm.hdu.edu.cn/showproblem.php?pid=4951 2014多校 第八题 1008 2014 Multi-University Training Contes ...

  2. 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 ...

  3. cf448D Multiplication Table

    D. Multiplication Table time limit per test 1 second memory limit per test 256 megabytes input stand ...

  4. Codeforces Round #256 (Div. 2) D. Multiplication Table(二进制搜索)

    转载请注明出处:viewmode=contents" target="_blank">http://blog.csdn.net/u012860063?viewmod ...

  5. 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 ...

  6. Codeforces 448 D. Multiplication Table

    二分法判断答案 D. Multiplication Table time limit per test 1 second memory limit per test 256 megabytes inp ...

  7. Codeforces 448 D. Multiplication Table 二分

    题目链接:D. Multiplication Table 题意: 给出N×M的乘法矩阵要你求在这个惩罚矩阵中第k个小的元素(1 ≤ n, m ≤ 5·10^5; 1 ≤ k ≤ n·m). 题解: n ...

  8. [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 ...

  9. [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 ...

  10. 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 ...

随机推荐

  1. javaweb项目的优化 - 几番思念

    简单地来看一个浏览器用户访问的流程: 浏览器->服务器->返回结果显示  这么简单地看,可能想得到的优化手段很少,常见的可能就是优化sql,加快数据库处理:加个缓存,加快返回:使用静态文件 ...

  2. linux —— shell 编程(整体框架与基础笔记)

    导读 关于shell编程基础的学习,网上有很多资源,如果在校图书馆应该也有一些教程,所以这里对于零碎的基础不做详细记录,而只是对一些常用的概念.命令与操作做一个简要的记录,以备方便查找. (本文所有语 ...

  3. Mac内建Apache

    打开终端 重启apache:sudo /usr/sbin/apachectl restart 关闭apache:sudo /usr/sbin/apachectl stop 开启apache:sudo ...

  4. Android Fragment生命周期及静态加载

    一个Fragment必须总是被嵌入到一个Activity中,它的生命周期直接被其所属的宿主Activity生命周期影响,它的状态会随宿主的状态变化而变化. 要创建一个Fragment 必须创建一个Fr ...

  5. hdu 3642 Get The Treasury(扫描线)

    pid=3642" style="">题目链接:hdu 3642 Get The Treasury 题目大意:三维坐标系,给定若干的长方体,问说有多少位置被覆盖3次 ...

  6. mysql在高内存、IO利用率上的几个优化点 (sync+fsync) 猎豹移动技术博客

    http://dev.cmcm.com/archives/107 Posted on 2014年10月16日 by liuding | 7条评论 以下优化都是基于CentOS系统下的一些优化整理,有不 ...

  7. [转] shared_from_this 几个值得注意的地方

    http://hi.baidu.com/cpuramdisk/item/7c2f8d77385e0f29d7a89cf0 shared_from_this()是enable_shared_from_t ...

  8. HighCharts常用设置(摘抄笔录)

  9. BestCoder 1st Anniversary

    Souvenir  Accepts: 1078  Submissions: 2366  Time Limit: 2000/1000 MS (Java/Others)  Memory Limit: 26 ...

  10. HTML5 FileAPI读取实例---(一)

    在HTML5中,提供了一个关于文件操作的API,通过这个API,对于从web页面上访问本地文件系统的相关处理变得十分简单.到目前为止只有部分浏览器对它提供支持. 1.FileList对象和File对象 ...