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 ...
随机推荐
- Spring Mobile是如何判断访问设备的类型的
Spring最近换域名了,去转转,发现了一个有意思的项目:spring mobile. http://projects.spring.io/spring-mobile/ 这个项目有很多实用的功能,如识 ...
- EF具体用在什么类型的项目上
一般来说,使用EF框架,肯定会比直接使用ADO.NET,消耗的时间多一些. 因为使用ADO.NET直接把SQL语句传回数据库执行. 而使用EF框架的话,会把所用到的尸体,转换成相对应得SQL,然后再传 ...
- 使用python进行加密解密AES算法
使用python进行加密解密AES算法-代码分享-PYTHON开发者社区-pythoner.org 使用python进行加密解密AES算法 TY 发布于 2011-09-26 21:36:53,分类: ...
- 4. Qt的容器类
Qt提供来一组通用的基于模板的容器类. 一. QList类,QLinkedList类 和 QVector类 QList类.QLinkedList类和QVector类常常使用到的Q ...
- java.util.Queue用法
队列是一种特殊的线性表,它只允许在表的前端(front)进行删除操作,而在表的后端(rear)进行插入操作.进行插入操作的端称为队尾,进行删除操作的端称为队头.队列中没有元素时,称为空队列. 在队列这 ...
- 熬之滴水穿石:JSP--HTML中的JAVA代码(6)
39--JSTL 在JSP编码中需考虑的一种方法,因为这种方法可以 ...
- Webbrowser加载Flash后方向键失效问题(用到了OLE接口,没有被处理就转发,够复杂的)
原文:http://blog.csdn.net/dropme/article/details/6253528 窗体上放一个ApplicationEvent控件,OnMessage事件中这么写 uses ...
- 一个完善的ActiveX Web控件教程
免费打工仔:一个完善的ActiveX Web控件教程 出自Ogre3D开放资源地带 跳转到: 导航, 搜索 原作者 David Marcionek. 翻译 免费打工仔 这个教程可以帮助你快速开发一 ...
- 【Demo 0003】Java基础-数组
本章学习要点: 1. 了解数组的基本概念: 2. 掌握数组使用方法: 一.数组的基本概念 1. 数组定义: 同一数据类型数据的集合,在 ...
- ios捕获异常并发送图片,便于解决bug
在开发过程中,我们有时候会留下Bug,用户在使用我们的app 的时候,有时会出现闪退,这时候我们能够让用户给我们发送邮件,以让我们开发者更加高速的地位到Bug的所在.以最快的时间解决.同一时候也提高用 ...