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 ...
随机推荐
- MRCP接口MRCPRecog 简介
功能:开始一个语音识别,一边讲话,一边识别,需要ASR服务器. 原型:MRCPRecog (grammar, options) grammar ---- 语法文件,可以是一个xml文件 options ...
- 无法访问Eureka主页
spring: application: name: 90foodmall-eureka server: port: 8000 eureka: client: #是否将自己注册到Eureka Serv ...
- ssh访问ubuntu13.10
步骤: 首先确保网络连接是ok,网络连接方式"桥接“,手动配置 ip 192.168.1.9,和主机是同一网段 1.检查当前有没有安装openssh-server(已安装) 2. 安装ope ...
- 5G时代,行业市场用户的公网与专网如何选择
导读 今年,5G开启了真刀真枪的商用元年,尤其中国5G正式启动商用服务,5G规模商用进程再次大提速.除了面向消费者领域,5G更大的商业价值还是寄望于进入各个垂直行业,赋能千行百业数字化转型. 5G进入 ...
- C++获取驱动盘句柄
转载:https://www.cnblogs.com/sherlock-merlin/p/10792116.html https://univasity.iteye.com/blog/8052 ...
- iOS 批量上传图片的 3 种方法
AFNetworking 在去年年底升级到了 3.0.这个版本更新想必有很多好处,然而让我吃惊的是,它并没有 batch request 接口.之前的 1.x 版本.2.x 版本都实现了这个很常见的需 ...
- vue动画钩子
<template> <div class="hello"> <div class="toggle" @click="f ...
- pip升级报错(权限问题)
今天跟新pip的时候错一个接一个 看到拒绝访问应该是权限的问题,想起安装的时候选择谁可以使用软件(大概是这样的一个选项),选择了“只有我”,选择所有用户应该就不会存在这个问题了,那么怎么解决呢? 敲黑 ...
- Android中的Sqlite中的onCreate方法和onUpgrade方法的执行时机--(转)
原文:http://blog.csdn.net/jiangwei0910410003/article/details/46536329 今天在做数据库升级的时候,遇到一个问题,就是onCreate方法 ...
- 一、iBatis进行分页查询
1.ibatis理解: iBatis属于半自动化的ORM框架,我们需要编写SQL语句,由iBatis进行数据库访问,返回结果.而iBatis可以为我们做的更多,比如对查询参数集合.结果.分页查询.事务 ...