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 ...
随机推荐
- SQL SERVER之数据查询
本篇主要解说查询语句,全部的演示样例都会依照以下这张表进行. stuID stuName age sex 11090241031 王小虎 21 男 11090241032 王小六 22 男 11 ...
- C# 它 抽象类和接口
抽象类 C#同意把类和方法声明为abstract,即抽象类和抽象方法.抽象类通常代表一个抽象概念,它提供一个继承的出发点,当设计一个新的对象类时,一定是用来继承的,所以,在一个以继承关系形成的等级结构 ...
- 简化ui文件转换写法
在命令行敲一串长的命令.枯燥麻烦. #coding:utf-8 import sys import os import subprocess if len(sys.argv) == 2: #节省输入, ...
- c#后台弹出提示
Page.ClientScript.RegisterClientScriptBlock(typeof(string), "", @"<script>alert ...
- Servlet的学习之Response响应对象(2)
本篇接上一篇<Servlet的学习之Response响应对象(1)>,继续从HttpServletResponse响应对象来介绍其方法和功能. 使用setHeader方法结合HTTP协议的 ...
- vue.js+boostrap
vue.js+boostrap最佳实践 一.为什么要写这篇文章 最近忙里偷闲学了一下vue.js,同时也复习了一下boostrap,发现这两种东西如果同时运用到一起,可以发挥很强大的作用,boostr ...
- 阿斯钢iojeg9uhweu9erhpu9hyw49
http://www.huihui.cn/share/8424421 http://www.huihui.cn/share/8424375 http://www.huihui.cn/share/842 ...
- Python标准库:内置函数dict(iterable, **kwarg)
本函数是从可迭代对象来创建新字典.比方一个元组组成的列表,或者一个字典对象. 样例: #dict() #以键对方式构造字典 d1 = dict(one = 1, two = 2, a = 3) pri ...
- Codeforces Round #256 (Div. 2) 题解
Problem A: A. Rewards time limit per test 1 second memory limit per test 256 megabytes input standar ...
- ContentProvider简要
1.什么是ContentProvider 数据库在Android其中是私有的,当然这些数据包含文件数据和数据库数据以及一些其它类型的数据. 不能将数据库设为WORLD_READABLE,每一个数据 ...