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. mac 终端连接服务器报错

    今天在连接虚拟机服务器时突然报了一个 WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!的错误.  会出现这个错误的原因是在第一次进行SSH连接时,会生 ...

  2. New Airless Pump Bottle Technical Features

    Airless Pump Bottle    protect sensitive products such as natural skin creams, serums, foundations a ...

  3. PAT T1005 Programming Pattern

    建立后缀数组,遍历height数组找到连续大于len的最长子序列~ #include<bits/stdc++.h> using namespace std; ; char s[maxn]; ...

  4. 解决Hibernate配置文件不在SRC文件夹下获取Session方法

  5. shell脚本中执行shell脚本(2)

    (a.sh)读取用户输入参数,并在脚本(b.sh)中使用 1.a.sh #!/bin/sh read -p "please input name value: " name ./b ...

  6. 避免学习Linux走弯路

    我并不是一位Linux老鸟.在学习Linux的一路上.也是走了很多弯路,踩了不少坑.而今日就把自己趟过的那些坑给我们总结出来,期望能给初学Linux的童靴们带来一丝丝的帮助吧.文采可能没有那么高深,只 ...

  7. Educational Codeforces Round 73 (Rated for Div. 2)D(DP,思维)

    #define HAVE_STRUCT_TIMESPEC#include<bits/stdc++.h>using namespace std;long long a[300007],b[3 ...

  8. R语言 table()函数

    table函数 用 table() 函数统计因子各水平的出现次数(称为频数或频率).也可以对一般的向量统计每个不同元素的出现次数.如 sex = c("女","女&quo ...

  9. js中每隔一段时间执行一次

    window.setInterval("flushs()",1000); 

  10. CentOS安装后的第一步:配置IP地址

    有关于centos7获取IP地址的方法主要有两种,1:动态获取ip:2:设置静态IP地址 在配置网络之前我们先要知道centos的网卡名称是什么,centos7不再使用ifconfig命令,可通过命令 ...