博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Codeforces Round #256 (Div. 2) D. Multiplication Table 二分法
阅读量:5281 次
发布时间:2019-06-14

本文共 1589 字,大约阅读时间需要 5 分钟。


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

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.

Sample test(s)
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 32 4 6
题意:给一个n*m的乘法表找第k大的数。
思路:二分。对于每一行找比mid小的数的个数加起来假设等于k就找到啦。
AC代码:
#include 
#include
using namespace std;typedef long long ll;ll solve(ll x,int n,int m){ ll res=0; for(int i=1;i<=n;i++){ res+=min((ll)m,x/i); } return res;}int main(){ int n,m; ll k; scanf("%d%d",&n,&m); cin>>k; ll l=1,r=(ll)n*m+1; while(l

转载于:https://www.cnblogs.com/bhlsheji/p/4572945.html

你可能感兴趣的文章
实训第五天
查看>>
平台维护流程
查看>>
2012暑期川西旅游之总结
查看>>
12010 解密QQ号(队列)
查看>>
2014年辛星完全解读Javascript第一节
查看>>
装配SpringBean(一)--依赖注入
查看>>
java选择文件时提供图像缩略图[转]
查看>>
方维分享系统二次开发, 给评论、主题、回复、活动 加审核的功能
查看>>
Matlab parfor-loop并行运算
查看>>
string与stringbuilder的区别
查看>>
2012-01-12 16:01 hibernate注解以及简单实例
查看>>
iOS8统一的系统提示控件——UIAlertController
查看>>
PAT甲级——1101 Quick Sort (快速排序)
查看>>
python创建进程的两种方式
查看>>
1.2 基础知识——关于猪皮(GP,Generic Practice)
查看>>
迭代器Iterator
查看>>
java易错题----静态方法的调用
查看>>
php建立MySQL数据表
查看>>
最简单的线程同步的例子
查看>>
旅途上看的电影和观后感
查看>>