二分法判断答案

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

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 3
2 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;
}

版权声明:来自: 代码代码猿猿AC路 http://blog.csdn.net/ck_boss

Codeforces 448 D. Multiplication Table的更多相关文章

  1. Codeforces 448 D. Multiplication Table 二分

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

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

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

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

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

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

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

  7. Day8 - D - Multiplication Table CodeForces - 448D

    Bizon the Champion isn't just charming, he also is very smart. While some of us were learning the mu ...

  8. CodeForces 448

    A:Rewards: 题目链接:http://codeforces.com/problemset/problem/448/A 题意:Bizon有a1个一等奖奖杯,a2个二等奖奖杯,a3个三等奖奖杯,b ...

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

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

随机推荐

  1. Linux date -s(转)

    修改linux的时间可以使用date指令 修改日期: 时间设定成2009年5月10日的命令如下: #date -s 05/10/2009 修改时间: 将系统时间设定成上午10点18分0秒的命令如下.  ...

  2. Java实现字符全阵列阵列

    import org.junit.Test; public class AllSort { public void permutation(char[] buf, int start, int end ...

  3. 【原创】shadowebdict开发日记:基于linux的简明英汉字典(二)

    全系列目录: [原创]shadowebdict开发日记:基于linux的简明英汉字典(一) [原创]shadowebdict开发日记:基于linux的简明英汉字典(二) [原创]shadowebdic ...

  4. 瑞丽的SQL-SQL Server的表旋转(行列转换)

    所谓表旋转,就是将表的行转换为列,或是将表的列转换为行,这是从SQL Server 2005開始提供的新技术.因此,如果希望使用此功能,须要将数据库的兼容级别设置为90.表旋转在某些方面也是攻克了表的 ...

  5. UDP议定书图像高速传输无损失程序

    下面的程序实现UDP没有图像数据的高速传输协议损耗,测试数据egtest01图片库,实现PC和图像的传输嵌入式结束.变速箱+读写速度可以达到10+M/S.考 server端程序 #include &l ...

  6. 解决编译时出错提示: 'error: array must be initialized with a brace-enclosed initializer' 的错误

    编译出现这个错误的原因非常简单编译的标准不相同.如果用stdc90,这个就可以直接编译通过了. 下面是代码例子: ...... ] = NULL;或者 :char cmd[256] = '\0'; . ...

  7. HDU 1695 GCD 欧拉函数+容斥原理+质因数分解

    链接:http://acm.hdu.edu.cn/showproblem.php?pid=1695 题意:在[a,b]中的x,在[c,d]中的y,求x与y的最大公约数为k的组合有多少.(a=1, a ...

  8. Directx11学习笔记【十八】 Blending混合

    本文由zhangbaochong原创,转载请注明出处http://www.cnblogs.com/zhangbaochong/p/5634580.html 在d3d11中是按frame来渲染物体的,在 ...

  9. FTP文件操作之创建目录

    前面几篇博客讲的都是对文件的操作,今天跟大家说一说对目录的操作,先让我们从创建目录开始说起吧. 创建目录很简单,首先创建一个ftp对象,然后将参数传进去,接着告诉ftp对象需要执行什么操作即可. 下面 ...

  10. 从头开始编写项目Makefile(八):型号规则

    [版权声明:转载请保留源:blog.csdn.net/gentleliu.Mail:shallnew at 163 dot com]     上创建的文件夹谈及.没有生产目标文件到相应的文件夹,在这里 ...