Multiplication Table (二分)
来源:互联网 发布:中国网络零售交易额 编辑:程序博客网 时间:2024/05/21 21:49
Description
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 ann × 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.
Sample Input
2 2 2
2
2 3 4
3
1 10 5
5
Hint
A 2 × 3 multiplication table looks like this:
1 2 32 4 6
#include<cstdio>#include<iostream>using namespace std;long long n,m,k;bool judge(long long mid){ long long ans = 0 , temp; for(long long i = 1 ; i <= n ; i++) { temp = min(i * m , mid); ans += temp / i; } return ans < k;}int main(){ while(~scanf("%lld%lld%lld",&n,&m,&k)) { long long l = 1 , r = n * m; while(l < r) { long long mid = (l + r) / 2; if(judge(mid)) l = mid + 1; else r = mid; } printf("%lld\n",r); } return 0;}
- Multiplication Table (二分)
- CF448D:Multiplication Table(二分)
- 【CodeForces】448D - Multiplication Table(二分)
- Codeforces 448D Multiplication Table(二分)
- CodeForces 448D Multiplication Table (二分 )
- CodeForces 448D Multiplication Table (二分 )
- cf448D. Multiplication Table【二分】
- Multiplication Table 【二分】
- Multiplication Table (二分)
- codeforces448D Multiplication Table(二分答案)
- D. Multiplication Table 二分查找
- Codeforces 448D: Multiplication Table(二分+数学)
- CF 256# D. Multiplication Table 二分
- codeforces D. Multiplication Table 二分答案
- CodeForces 448D - Multiplication Table(二分)
- Codeforces Round #256 (Div. 2) D. Multiplication Table(二分查找)
- Codeforces Round #256 (Div. 2) D Multiplication Table(很巧妙二分)
- CodeForces 448D Multiplication Table(二分,CodeForces,矩阵中找数字)
- 怎样在VS2010中打开VS2012的项目
- Js基础学习之-- 利用正则表达式验证 模拟注册界面
- java记事本源代码
- poj 1696 Space Ant 计算几何
- Android开发常用工具类之File操作
- Multiplication Table (二分)
- 设置导航栏透明
- FragmentPagerAdapter
- Codeforces Round #177 (Div. 1) C. Polo the Penguin and XOR operation(贪心)
- 我的JavaScript笔记
- python基础语法(1)
- memwatch使用
- 进程通信之文件读写
- 【TomoEngine】 第六讲 基于TomoEngine的3D产品(游戏/应用)制作流程