Day8 - D - Multiplication Table CodeForces - 448D
Bizon the Champion isn't just charming, he also is very smart.
While some of us were learning the multiplication table, Bizon the Champion had fun in his own manner. Bizon the Champion painted an n × m multiplication table, where the element on the intersection of the i-th row and j-th column equals i·j (the rows and columns of the table are numbered starting from 1). Then he was asked: what number in the table is the k-th largest number? Bizon the Champion always answered correctly and immediately. Can you repeat his success?
Consider the given multiplication table. If you write out all n·m numbers from the table in the non-decreasing order, then the k-th number you write out is called the k-th largest number.
Input
The single line contains integers n, m and k (1 ≤ n, m ≤ 5·105; 1 ≤ k ≤ n·m).
Output
Print the k-th largest number in a n × m multiplication table.
Examples
2 2 2
2
2 3 4
3
1 10 5
5
Note
A 2 × 3 multiplication table looks like this:
1 2 3
2 4 6 思路:二分套二分,二分每个数,求出是第几大,每次比较一列,该列中比他小的数就是min(x,i*n)/i(i表示第几列)
typedef long long LL;
typedef pair<LL, LL> PLL; LL n, m, k; LL check(LL x) {
LL ret = , b;
for(LL i = ; i <= m; ++i) {
b = min(x, i*n);
ret += b/i;
}
return ret;
} int main() {
ios::sync_with_stdio(false), cin.tie();
cin >> n >> m >> k;
LL l = , r = n*m, mid, ans;
while(l <= r) {
mid = (l + r) >> ;
if(check(mid) >= k) {
ans = mid;
r = mid - ;
} else
l = mid + ;
}
cout << ans << "\n";
return ;
}
Day8 - D - Multiplication Table CodeForces - 448D的更多相关文章
- 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 ...
- Codeforces Round #256 (Div. 2) D. Multiplication Table(二进制搜索)
转载请注明出处:viewmode=contents" target="_blank">http://blog.csdn.net/u012860063?viewmod ...
- Codeforces Round #586 (Div. 1 + Div. 2) B. Multiplication Table
链接: https://codeforces.com/contest/1220/problem/B 题意: Sasha grew up and went to first grade. To cele ...
- 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 ...
- 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 ...
- hdu4951 Multiplication table (乘法表的奥秘)
http://acm.hdu.edu.cn/showproblem.php?pid=4951 2014多校 第八题 1008 2014 Multi-University Training Contes ...
- cf448D Multiplication Table
D. Multiplication Table time limit per test 1 second memory limit per test 256 megabytes input stand ...
随机推荐
- Mybatis plus 插入数据时将自动递增的主键手动进行赋值设置
1.首先设置好实体类:将类型设置为 @TableId(type = IdType.INPUT) 2.在插入数据前将id赋值给实体类对象即可
- windows 以太坊开发框架Truffle环境搭建
https://www.jianshu.com/p/f7a4de0cba9d 一.安装DApp开发环境 1.1 安装Node.js 我们使用官方长期支持的8.10.0LTS版本,下载64位包装包. 下 ...
- 吴裕雄 Bootstrap 前端框架开发——Bootstrap 显示代码:按键提示
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title> ...
- mybatis 查询标签
语法 参考:http://www.mybatis.org/mybatis-3/zh/dynamic-sql.html <![CDATA[内容]]>: 参考: http://blog.csd ...
- Unity表面着色器
表面着色器和之前无光照着色器不同,其中没有顶点着色器和片元着色器,而增加了光照函数: 接下写了一个求两个贴图的光照效果 两个贴图做插值运算: Shader "Custom/SurfaceSh ...
- 【PAT甲级】1032 Sharing (25 分)
题意: 输入两个单词的起始地址和一个正整数N(<=1e5),然后输入N行数据,每行包括一个五位数的字母地址,字母和下一个字母的地址.输出这两个单词的公共后缀首字母的地址,若无公共后缀则输出-1. ...
- FFmpeg——AVCodec,AVCodecContext,AVCodecParameters 辨析
先贴上雷神的一张FFmpeg关键结构体之间的关系图: 再看雷神的分析: 每个AVStream存储一个视频/音频流的相关数据: 每个AVStream对应一个AVCodecContext,存储该视频/音频 ...
- hdu 1086 You can Solve a Geometry Problem too 求n条直线交点的个数
You can Solve a Geometry Problem too Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/3 ...
- A. Hotelier
A. Hotelier 题意:一家有10间房间的旅馆(10个房间排成一排),在旅馆的左右两端都有一个办理入住的前台,L代表在左端办理入住,R代表在右端办理入住,顾客都会挑选距离最近的空房间入住,数 ...
- 四、spring集成ibatis进行项目中dao层基类封装
Apache iBatis(现已迁至Google Code下发展,更名为MyBatis)是当前IT项目中使用很广泛的一个半自动ORM框架,区别于Hibernate之类的全自动框架,iBatis对数据库 ...