codeforces#256DIV2 D题Multiplication Table
题目地址:http://codeforces.com/contest/448/problem/D
当时是依照找规律做的,规律倒是找出来了,可是非常麻烦非常麻烦。
。
看到前几名的红名爷们3分钟就过了,于是果断放弃了。
。赛后才知道是用二分的方法做,知道了二分之后。剩下的就非常easy了。。关键在于能不能想到用二分。。
代码例如以下:
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <ctype.h>
#include<algorithm> using namespace std; int main()
{
__int64 low, high, mid, x, ans, s1, s2, n, m, k, i;
scanf("%I64d%I64d%I64d",&n,&m,&k);
high=n*m;
low=1;
while(low<=high)
{
mid=(low+high)/2;
s1=s2=0;
for(i=1;i<=n;i++)
{
x=mid/i;
if(x>m)
{
s1+=m;
}
else
{
if(mid%i==0)
{
s2++;
s1+=x-1;
}
else
{
s1+=x;
}
}
}
if(k>=s1+1&&k<=s1+s2)
{
ans=mid;
break;
}
else if(k>s1+s2)
{
low=mid+1;
}
else
{
high=mid-1;
}
}
printf("%I64d\n",ans);
return 0;
}
codeforces#256DIV2 D题Multiplication Table的更多相关文章
- 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 #256 (Div. 2) D. Multiplication Table(二进制搜索)
转载请注明出处:viewmode=contents" target="_blank">http://blog.csdn.net/u012860063?viewmod ...
- Codeforces 448 D. Multiplication Table 二分
题目链接:D. Multiplication Table 题意: 给出N×M的乘法矩阵要你求在这个惩罚矩阵中第k个小的元素(1 ≤ n, m ≤ 5·10^5; 1 ≤ k ≤ n·m). 题解: n ...
- 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 ...
- 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 ...
- Codeforces 448 D. Multiplication Table
二分法判断答案 D. Multiplication Table time limit per test 1 second memory limit per test 256 megabytes inp ...
- 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 ...
- 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 ...
- hdu4951 Multiplication table (乘法表的奥秘)
http://acm.hdu.edu.cn/showproblem.php?pid=4951 2014多校 第八题 1008 2014 Multi-University Training Contes ...
随机推荐
- c语言,gdb
Get gdb call stack http://blog.csdn.net/zoufeiyy/article/details/1490241 Debugging with GDB - Examin ...
- Mac 实用工具
命令行常用工具: Iterm2 也是一个终端命令行工具,支持多工作区,使用清爽 http://www.iterm2.com/documentation.html 给你的命令行 代码上色 Solariz ...
- perl Exporter一些神奇写法
use base qw(Exporter); @JSON::EXPORT = qw(from_json to_json jsonToObj objToJson encode_json decode_j ...
- 怎样在Windows和Linux下写相同的代码
目前,Linux在国内受到了越来越多的业内人士和用户的青睐.相信在不久的将来,在国内为Linux开发 的应用软件将会有很大的增加(这不,金山正在招兵买马移植WPS呢).由于未来将会是Windows和L ...
- okHttp封装使用
package com.zhy.utils.http.okhttp; import android.graphics.Bitmap; import android.graphics.BitmapFac ...
- find-a-jar-file-given-the-class-name
Save this as findclass.sh (or whatever), put it on your path and make it executable: #!/bin/sh find ...
- Jrebel 6.2.1破解
个人微信:benyzhous,可以一起探讨 云盘下载链接: http://pan.baidu.com/s/1bnGzMUF 配置: -noverify -javaagent:/Users/chabab ...
- XP教育网用户免费上网
本文针对 XP 教育网用户免费上网,其他系统未作测试.若有疑问百度空间留言 http://hi.baidu.com/itas109 http://blog.csdn.net/itas109 步骤 ...
- Matlab的parfor并行编程
Matlab的parfor并行编程 通常消耗最多计算资源的程序往往是循环. 把循环并行化.或者优化循环体中的代码是最经常使用的加快程序执行速度的思路. Matlab提供了parforkeyword,能 ...
- RGB HSV HLS三种色彩模式转换(C语言实现)
Android项目上处理图像的代码(注释全部去掉) ? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 ...