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 ...
随机推荐
- php基础(七)文件
PHP 文件处理 PHP 操作文件 当您操作文件时必须非常小心.如果您操作失误,可能会造成非常严重的破坏.常见的错误是: 编辑错误的文件 被垃圾数据填满硬盘 意外删除文件内容 PHP readfile ...
- 判断浏览器是否支持html5和css3属性
本文章内容是由一个前辈写的. CSS3特有的属性moz-Transform //判断是否具有相应属性 testProps: function (props) { var i; for (i in pr ...
- 正方形网格 TRIANGLE_STRIP连接
unsigned int vIdx = 0, iIdx = 0; for (unsigned int stripRow = 0; stripRow < stripRows; stripRow++ ...
- OSG+Python
测试平台(1)Fedora19 x86 [cc@localhost ~]$ lspci | grep VGA :) :00.0 VGA compatible controller: NVIDIA Co ...
- RocketMQ初步应用架构理论
RocketMQ初步应用架构理论 写给RocketMQ架构应用入门,内容涉及它的设计机理以及推到出来的应用注意事项,入门人员请看. 稍微涉及技术细节,留以我设计中间件时参考,将来整理深度文档时会抽取走 ...
- aspnet5备忘
1. 在Windows下面运行cmd,然后执行下面的命令 @powershell -NoProfile -ExecutionPolicy unrestricted -Command "&am ...
- 抛弃阿里云,中国用户购买海外VPS的五个理由
王掌柜在过去的五年多时间里,折腾过不少vps品牌,最开始玩的是一年一百多块钱的香港虚拟主机,后来业务量大了,开始折腾国内的小鸟云.阿里云.腾讯云.电信云.百度云主机,国外的linode\interse ...
- python--随机函数(random,uniform,randint,randrange,shuffle,sample)
random() random()方法:返回随机生成的一个实数,它在[0,1)范围内 运用random()方法的语法: import random #random()方法不能直接访问,需要导入rand ...
- 查找一个数组中最小的前n项
/****************************************************************** find the biggest x number in a s ...
- oracle 导入sql中文乱码(转)
导入sql的有中文,直接在linux环境下进行复制粘贴的,发现进去的都是乱码, 修改如下: 进入oracle用户,#vi /home/oracle/.bash_profile; 在最后一行添加:exp ...