二分法判断答案

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

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

Codeforces 448 D. Multiplication Table相关推荐

  1. C - Multiplication Table CodeForces - 448D

    C - Multiplication Table CodeForces - 448D 题目: Problem Description Bizon the Champion isn't just cha ...

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

  3. Codeforces Round #586 (Div. 1 + Div. 2) B. Multiplication Table 思维 + 公式

    传送门 文章目录 题意: 思路: 题意: 给你一个n∗nn*nn∗n的矩阵,每个位置由ai∗aja_i*a_jai​∗aj​得来,主对角线为000,让你求出来aia_iai​. n≤1e3n\le1e ...

  4. codeforces 577A Multiplication Table【思维】

    codeforces 577A Multiplication Table Let's consider a table consisting of n rows and n columns. The ...

  5. Codeforces Round #256 (Div. 2) D Multiplication Table

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

  6. CodeForces 448

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

  7. LeetCode hard 668. Kth Smallest Number in Multiplication Table(二分答案)

    题目:https://leetcode.com/problems/kth-smallest-number-in-multiplication-table/description/ Kth Smalle ...

  8. CodeForces - 1220B Multiplication Table(思维)

    题目链接:点击查看 题目大意:给出一个n*n的矩阵,初始时有一个数组a,矩阵中的每个M[i][j]=a[i]*a[j],现在对角线缺失,需要我们构造一种数组a的情况 题目分析:其实稍微分析一下就能看出 ...

  9. Codeforces 338 D. GCD Table

    http://codeforces.com/problemset/problem/338/D 题意: 有一张n*m的表格,其中第i行第j列的数为gcd(i,j) 给出k个数 问在这张表格中是否 有某一 ...

  10. Codeforces 40 E. Number Table

    题目链接:http://codeforces.com/problemset/problem/40/E 妙啊... 因为已经确定的格子数目严格小于了$max(n,m)$,所以至少有一行或者一列是空着的, ...

最新文章

  1. 使用Native API 创建进程
  2. Axure 部件的交互样式
  3. 一篇文章对Python匿名函数配合容器函数的使用理解
  4. PHP中的Trait方法
  5. Unity中UGUI之Canvas属性解读版本二
  6. 如鹏网学习笔记(十二)HTML5
  7. launchMode的几种模式
  8. go 变量大写_和我一起学Go系列:Go基本语法概览
  9. 迅捷PDF转换器特点和使用步骤
  10. cout, endl的使用
  11. 响铃:社交型流量平台,为何线上平台都扎堆去线下造节
  12. 墙裂推荐5款做微商必备的软件
  13. java excel 判断组重复_Java判断Excel某列是否有重复值
  14. 机器学习和深度学习相关问题总结
  15. Java扫雷游戏心得体会总结_Java扫雷游戏: JMine
  16. 开源BI平台软件特性对比
  17. 访问到页面的完整流程
  18. vulnhub——Empire:LupinOne
  19. AndroidStudio制作“我”的界面,设置,修改密码,设置密保和找回密码
  20. 欧姆龙CP1H如何进行PLC远程编程及数据采集

热门文章

  1. android中得到屏幕的高宽(像素)
  2. 使用锚标记返回网页顶部的方法
  3. 大学生就业新神器 网络电话“通”职场
  4. 传富士康将在印度建世界最大代工厂
  5. VCSA 6.5 HA配置 之一:架构概览
  6. Spring AOP会忽略从父类继承的方法
  7. python第三方模块
  8. 深入了解 Dojo 的服务器推送技术
  9. 微软MCITP系列课程(二四)利用组策略部署软件
  10. POJ_1753解答过程的理解