689C - Mike and Chocolate Thieves 二分
题目大意:有四个小偷,第一个小偷偷a个巧克力,后面几个小偷依次偷a*k,a*k*k,a*k*k*k个巧克力,现在知道小偷有n中偷法,求在这n种偷法中偷得最多的小偷的所偷的最小值。
题目思路:二分查找偷得最多的小偷所偷的数目,并遍历k获取该数目下的方案数。脑子一抽将最右端初始化做了1e15,wa了n多次……
#include<iostream>
#include<algorithm>
#include<cstring>
#include<vector>
#include<stdio.h>
#include<stdlib.h>
#include<queue>
#include<math.h>
#include<map>
#define INF 0xffffffff
#define MAX 1e18
#define Temp 1000000000
#define MOD 1000000007 using namespace std; long long n;
int ok; long long Check(long long m)
{
long long ans=;
for(long long i=;i*i*i<=m;i++)
{
ans+=(m/(i*i*i));
}
return ans;
} long long Find()
{
long long L=,R=MAX,ans;
while(L<=R)
{
long long Mid=(L+R)/;
long long t =Check(Mid);
if(t > n)
R=Mid-;
else if(t < n)
L=Mid+;
else
{
ok=;
ans=Mid;
R=Mid-;
} }
return ans;
} int main()
{
while(scanf("%lld",&n)!=EOF)
{
ok=;
long long ans=Find();
if(!ok)
printf("-1\n");
else
printf("%lld\n",ans);
}
return ;
}
689C - Mike and Chocolate Thieves 二分的更多相关文章
- Codeforces 689C. Mike and Chocolate Thieves 二分
C. Mike and Chocolate Thieves time limit per test:2 seconds memory limit per test:256 megabytes inpu ...
- CodeForces 689C Mike and Chocolate Thieves (二分+数论)
Mike and Chocolate Thieves 题目链接: http://acm.hust.edu.cn/vjudge/contest/121333#problem/G Description ...
- codeforces 689C C. Mike and Chocolate Thieves(二分)
题目链接: C. Mike and Chocolate Thieves time limit per test 2 seconds memory limit per test 256 megabyte ...
- Codeforces Round #361 (Div. 2) C. Mike and Chocolate Thieves 二分
C. Mike and Chocolate Thieves 题目连接: http://www.codeforces.com/contest/689/problem/C Description Bad ...
- Codeforces Round #341 (Div. 2) C. Mike and Chocolate Thieves 二分
C. Mike and Chocolate Thieves time limit per test 2 seconds memory limit per test 256 megabytes inpu ...
- CodeForces 689C Mike and Chocolate Thieves (二分)
原题: Description Bad news came to Mike's village, some thieves stole a bunch of chocolates from the l ...
- CodeForces 689C Mike and Chocolate Thieves (二分最大化最小值)
题目并不难,就是比赛的时候没敢去二分,也算是一个告诫,应该敢于思考…… #include<stdio.h> #include<iostream> using namespace ...
- CodeForces 689C Mike and Chocolate Thieves
题目链接:http://acm.hust.edu.cn/vjudge/problem/visitOriginUrl.action?id=412145 题目大意:给定一个数字n,问能不能求得一个最小的整 ...
- codeforces 361 C - Mike and Chocolate Thieves
Time Limit:2000MS Memory Limit:262144KB 64bit IO Format:%I64d & %I64u Description Bad ...
随机推荐
- json解析的函数eval_r() 和 JSON.parse()
eval_r()解析的字符串格式是'({"data":"hello","num":"5"})' ...
- Python之列表&元组&字典
今天学习了Python的基本数据类型,做以下笔记,以备查用. 一.列表 列表的常用方法: 1.append()方法 def append(self, p_object): # real signatu ...
- openwrt拦截snmp报文
SNMP使用的协议为UDP,默认端口为161和162. 使用iptables 命令如下: iptables -A INPUT -p udp -m udp --dport 161:162 -j DROP ...
- html的表单表格...
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...
- 通过实例来理解ajax
点击一个按钮,然后将信息显示到指定的div内. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"& ...
- IE8“开发人员工具”使用详解上(各级菜单详解)
来源: http://www.cnblogs.com/JustinYoung/archive/2009/03/24/kaifarenyuangongju.html IE8“开发人员工具”使用详解上(各 ...
- oracle 导入sql中文乱码(转)
导入sql的有中文,直接在linux环境下进行复制粘贴的,发现进去的都是乱码, 修改如下: 进入oracle用户,#vi /home/oracle/.bash_profile; 在最后一行添加:exp ...
- 错误提示 Unsupported compiler 'com.apple.compilers.llvmgcc42' selected for architecture 'i386'
转自http://blog.csdn.net/cyuyanenen/article/details/51444974 警告提示:Invalid C/C++ compiler in target Cor ...
- CSSHack 兼容性
史上最全的CSS hack方式一览 CSS hack技巧大全 Can i use CSS hack CSS hack 由于不同厂商的流览器或某浏览器的不同版本(如IE6-IE11,Fire ...
- redis事务、管道及消息通知探究
一.事务 redis中使用事务,multi表示事务开始,对redis进行一些列操作之后再用exec提交事务,对应的方法分别是Transaction jedis.multi(),List<Obje ...