Codeforces 448 D. Multiplication Table
来源:互联网 发布:祛痘图片淘宝 编辑:程序博客网 时间:2024/05/26 19:19
二分判定答案
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.
The single line contains integers n, m and k (1 ≤ n, m ≤ 5·105; 1 ≤ k ≤ n·m).
Print the k-th largest number in a n × m multiplication table.
2 2 2
2
2 3 4
3
1 10 5
5
A 2 × 3 multiplication table looks like this:
1 2 32 4 6
#include <iostream>#include <cstdio>#include <cstring>#include <algorithm>#include <map>using namespace std;typedef long long int LL;LL n,m,k;bool ck(LL x){ LL nt=0; for(LL i=1;i<=n;i++) { nt+=min(m,x/i); } if(nt>=k) return true; return false;}int main(){ scanf("%I64d%I64d%I64d",&n,&m,&k); LL low=1,high=n*m,ans=-1,mid; while(low<=high) { mid=(low+high)/2; if(ck(mid)) { ans=mid; high=mid-1; } else low=mid+1; } printf("%I64d\n",ans); return 0;}
- Codeforces 448 D. Multiplication Table
- Codeforces 448D Multiplication Table
- Codeforces 448D Multiplication Table
- Codeforces 448 D. Multiplication Table
- 【CodeForces】[448D]Multiplication Table
- CodeForces 448D Multiplication Table
- codeforces D. Multiplication Table
- 【杂题】 codeforces 448D Multiplication Table
- 【CodeForces】448D - Multiplication Table(二分)
- Codeforces 448D Multiplication Table(二分)
- CodeForces 448D Multiplication Table (二分 )
- CodeForces 448D Multiplication Table (二分 )
- CodeForces 448D - Multiplication Table(二分)
- D. Multiplication Table 448D
- CodeForces - 448D—Multiplication Table--二分法(nlogn)
- Codeforces 448D: Multiplication Table(二分+数学)
- codeforces#256DIV2 D题Multiplication Table
- CodeForces 2014.7.17 D. Multiplication Table
- Centos 6.5 yum快速升级、修复OpenSSL heartbleed漏洞
- java使用反射调用set和get方法
- Map.entry优势
- 使用sortedArrayUsingSelector:方法排序数组中的元素
- POJ3126——Prime Path
- Codeforces 448 D. Multiplication Table
- Codeforces Round #256 (Div. 2) B
- 面试算法(四十)数组中只出现一次的数字
- 别把专业当生活,因为生活不分专业
- 程序员的好习惯
- 环保创业的可行之道——Leo鉴书上66
- [c++11] 判断类内是否有typedef某个名字的类型成员
- 什么是变量定义和变量声明
- 绘图与动画学习笔记(二)