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 ...
随机推荐
- 转载:Ununtu下中文乱码解决方案
转载: 添加中文字符编码: $sudo vim /var/lib/locales/supported.d/local #添加下面的中文字符集 zh_CN.GBK GBK zh_CN.GB2312 GB ...
- jiaocheng https://github.com/CarpenterLee/JCFInternals
https://github.com/CarpenterLee/JCFInternals
- do while 与while的区别!
#include "stdio.h" main() { ,b=; do{ //在这里do while 是先完成{}里的运算在判断while()里的循环// a=a+b; b++; ...
- redis 实时从mysql 更新数据
现在的互联网普遍都用redis+mysql ,查询一般放在 redis 上,更改 放在 redis 上, 如果更新 mysql数据到 redis 上呢? mysql 有四中类型的日志 Error ...
- iframe页面改动parent页面的隐藏input部件value值,不能触发change事件。
实现一个依据iframe页面返回充值卡类型不同,安排不同的input部件. 点击选择弹出一个iframe.点击充值卡数据行.返回1.充值卡类型.2.充值卡id(用的UUID).3.充值卡号(字符串). ...
- Ubuntu上glibc CVE-2015-7547漏洞的POC验证和修复
Ubuntu上查看Glibc版本 $ldd --version ldd (Ubuntu GLIBC 2.21-0ubuntu4) 2.21 Ubuntu上查看使用Glibc的相关程序 sudo lso ...
- 12、SQL Server 行列转换
SQL Server 行转列 在SQL Server 2005中PIVOT 用于将列值转换为列名(行转列),在SQL Server 2000中是没有这个关键字的 只能用case语句实现. --创建测试 ...
- Web字体库下载及转换工具
1.字体现在网站: http://ztxz.org/ 2.Web字体在线格式转换器: http://www.freefontconverter.com/ 3.
- java中的IO一
一.IO操作的目标 IO的流向 二.IO的分类方法 1.第一种分法:输入流.输出流 2.第二种分法:字节流.字符流 3.第三种分法:节点流.处理流 三.IO当中的核心类 核心类中的核心方法 Input ...
- JTree用法及JTree使用经验总结
import java.awt.Dimension; import java.awt.Color; import javax.swing.JFrame; import javax.swing. ...