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 nm 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

Input
2 2 2
Output
2
Input
2 3 4
Output
3
Input
1 10 5
Output
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的更多相关文章

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

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

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

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

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

  5. Codeforces 448 D. Multiplication Table

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

  6. Codeforces 448 D. Multiplication Table 二分

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

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

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

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

  9. cf448D Multiplication Table

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

随机推荐

  1. 通过getGeneratedKeys获取记录的主键

    Connection con=null; PreparedStatement ps=null; ResultSet rs=null; try { //建立连接 con= JDBCUtils.getCo ...

  2. PTA的Python练习题(一)

    最近宅家里没事干,顺便把python给学了.教程和书看了一段时间,但是缺少练习的平台. 想起大一时候练习C语言的PTA平台,就拿来练手了. (因为没有验证码无法提交题目,所以自己用pycharm来做题 ...

  3. Servlet 学习(八)

    Filter 1.功能 Java Servlet 2.3 中新增加的功能,主要作用是对Servlet 容器的请求和响应进行检查和修改 Filter 本身并不生成请求和响应对象,它只提供过滤作用 在Se ...

  4. c++模板(翁恺c++公开课[34-35]学习笔记)

    为什么要有模板(templates):当我们需要一个列表(list),列表中元素可能都为X类型也可能都为Y类型,怎么来实现呢? 定义基类?可以实现,很多情况下可能不够简明的表达设计思想 克隆代码(写一 ...

  5. JS原型与原型链继承的理解

    一.原型 先从构造函数开始吧! 构造函数是什么?构造函数与其他函数唯一的区别在于调用方式不同.任何函数只要通过new来调用就可以作为构造函数,它是用来创建特定类型的对象. 下面定义一个构造函数 Fem ...

  6. CSP-J2019 加工零件

    Background: 之前 $noip $死了,泥萌都说 \(noip SPFA\) 了,现在 \(noip\) 复活了,所以 \(SPFA\) 也复活了. (注:这里的 \(noip\) 跟 \( ...

  7. R-CNN算法中NMS的具体做法

    假设有20类,2000个建议框,最后输出向量维数2000*20,则每列对应一类,一行是各个建议框的得分,NMS算法步骤如下: ① 对2000×20维矩阵中每列按从大到小进行排序: ② 从每列最大的得分 ...

  8. 学习Java的书籍资料

    对于程序员来说,编程技术至关重要,然而技术的提高不是一蹴而就的,它需要时间的积累和经验的沉淀.因此本文为大家推荐Java学习的书籍,学虽容易,学好不易,且学且珍惜. 基础类.<Java从入门到精 ...

  9. 中山普及Day17——普及

    今天换教室,本来教室多好嘛,易守难攻,结果...今天今天仅下午就被熊抄了2次,熊超真TMD不是人呐,走路连脚步声都没有. 然后,播报分数: 爆0了!!!

  10. rundll32 常用命令

    Rundll32 常用命令列表(1) 下面是具体的Rundll32 的命令行列表: 添加删除程序 RunDll32.exe shell32.dll,Control_RunDLL appwiz.cpl, ...