Codeforces 448 D. Multiplication Table
二分法判断答案
1 second
256 megabytes
standard input
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.
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 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相关推荐
- C - Multiplication Table CodeForces - 448D
C - Multiplication Table CodeForces - 448D 题目: Problem Description Bizon the Champion isn't just cha ...
- 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 ...
- 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 ...
- codeforces 577A Multiplication Table【思维】
codeforces 577A Multiplication Table Let's consider a table consisting of n rows and n columns. The ...
- 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 ...
- CodeForces 448
A:Rewards: 题目链接:http://codeforces.com/problemset/problem/448/A 题意:Bizon有a1个一等奖奖杯,a2个二等奖奖杯,a3个三等奖奖杯,b ...
- LeetCode hard 668. Kth Smallest Number in Multiplication Table(二分答案)
题目:https://leetcode.com/problems/kth-smallest-number-in-multiplication-table/description/ Kth Smalle ...
- CodeForces - 1220B Multiplication Table(思维)
题目链接:点击查看 题目大意:给出一个n*n的矩阵,初始时有一个数组a,矩阵中的每个M[i][j]=a[i]*a[j],现在对角线缺失,需要我们构造一种数组a的情况 题目分析:其实稍微分析一下就能看出 ...
- Codeforces 338 D. GCD Table
http://codeforces.com/problemset/problem/338/D 题意: 有一张n*m的表格,其中第i行第j列的数为gcd(i,j) 给出k个数 问在这张表格中是否 有某一 ...
- Codeforces 40 E. Number Table
题目链接:http://codeforces.com/problemset/problem/40/E 妙啊... 因为已经确定的格子数目严格小于了$max(n,m)$,所以至少有一行或者一列是空着的, ...
最新文章
- 使用Native API 创建进程
- Axure 部件的交互样式
- 一篇文章对Python匿名函数配合容器函数的使用理解
- PHP中的Trait方法
- Unity中UGUI之Canvas属性解读版本二
- 如鹏网学习笔记(十二)HTML5
- launchMode的几种模式
- go 变量大写_和我一起学Go系列:Go基本语法概览
- 迅捷PDF转换器特点和使用步骤
- cout, endl的使用
- 响铃:社交型流量平台,为何线上平台都扎堆去线下造节
- 墙裂推荐5款做微商必备的软件
- java excel 判断组重复_Java判断Excel某列是否有重复值
- 机器学习和深度学习相关问题总结
- Java扫雷游戏心得体会总结_Java扫雷游戏: JMine
- 开源BI平台软件特性对比
- 访问到页面的完整流程
- vulnhub——Empire:LupinOne
- AndroidStudio制作“我”的界面,设置,修改密码,设置密保和找回密码
- 欧姆龙CP1H如何进行PLC远程编程及数据采集