二分法判断答案

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. Cocostudio学习笔记(4) LoadingBar+ TextField

    这同时录制两个控件的使用方法:LoadingBar和 TextField. -------------------------------------------------------------- ...

  2. [cocos2dx笔记008]cocos2d 用luabridge手动绑定类

    基于cocos2dx 2.2.2版本号.这几天使用了cocostudio实现了,动画.骨骼动画.UI编辑.粒子效果,尽管有些不足,但已经算是很好了.今天尝试用lua.这个很easy.创建的时候.设置语 ...

  3. 我不知道你是在一个多线程out该--【ITOO】

    仍向系统负载作出太慢.卡而发愁太?我不知道多线程,你们out该.最近花了大约两三天.多-threaded.通过团队的交流,多线程有更深入的思考.希望可以加入ITOO目里面,优化一下系统性能. 概念 线 ...

  4. 让Emeditor支持markdown编辑博客

    让Emeditor支持markdown编辑博客 1. 关于高亮显示 2.生成HTML文件并预览 用惯了Emeditor,最近又开始学习用markdown写博客,怎么让Emeditor支持markdow ...

  5. uva 11324 The Largest Clique(图论-tarjan,动态规划)

    Problem B: The Largest Clique Given a directed graph G, consider the following transformation. First ...

  6. __weak如何实现目标值自己主动设置nil的

    在开始评论__weak机制之前,首先,一些床上用品 ARC 实现 苹果公司的官方介绍说,.ARC这是"内存管理由编译器"的,但事实上,只有编译器不能完全胜任,ARC另外还要看OC执 ...

  7. Robotium调用getActivity()导致程序挂起的方法

    1. 问题背景的叙述性说明 需要直接用在工作中没有项目的源代码robotium测试目标android平台launcher,该平台的基础上,当前日期的版本号android 4.4.2.之前我用来验证的可 ...

  8. [原创].NET 业务框架开发实战之九 Mapping属性原理和验证规则的实现策略

    原文:[原创].NET 业务框架开发实战之九 Mapping属性原理和验证规则的实现策略 .NET 业务框架开发实战之九 Mapping属性原理和验证规则的实现策略 前言:之前的讨论一直关注在怎么从D ...

  9. java中三种常见内存溢出错误的处理方法(good)

    相信有一定java开发经验的人或多或少都会遇到OutOfMemoryError的问题,这个问题曾困扰了我很长时间,随着解决各类问题经验的积累以及对问题根源的探索,终于有了一个比较深入的认识. 在解决j ...

  10. 开源 自由 java CMS - FreeCMS2.0 举APP产生信息数据

    项目地址:http://www.freeteam.cn/ 生成信息数据 生成当前管理网站下同意移动APP訪问的栏目的信息页面. 从左側管理菜单点击生成信息数据进入. 您能够选择须要生成的栏目,然后点击 ...