题目大意:有四个小偷,第一个小偷偷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 二分的更多相关文章

  1. Codeforces 689C. Mike and Chocolate Thieves 二分

    C. Mike and Chocolate Thieves time limit per test:2 seconds memory limit per test:256 megabytes inpu ...

  2. CodeForces 689C Mike and Chocolate Thieves (二分+数论)

    Mike and Chocolate Thieves 题目链接: http://acm.hust.edu.cn/vjudge/contest/121333#problem/G Description ...

  3. codeforces 689C C. Mike and Chocolate Thieves(二分)

    题目链接: C. Mike and Chocolate Thieves time limit per test 2 seconds memory limit per test 256 megabyte ...

  4. 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 ...

  5. 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 ...

  6. CodeForces 689C Mike and Chocolate Thieves (二分)

    原题: Description Bad news came to Mike's village, some thieves stole a bunch of chocolates from the l ...

  7. CodeForces 689C Mike and Chocolate Thieves (二分最大化最小值)

    题目并不难,就是比赛的时候没敢去二分,也算是一个告诫,应该敢于思考…… #include<stdio.h> #include<iostream> using namespace ...

  8. CodeForces 689C  Mike and Chocolate Thieves

    题目链接:http://acm.hust.edu.cn/vjudge/problem/visitOriginUrl.action?id=412145 题目大意:给定一个数字n,问能不能求得一个最小的整 ...

  9. codeforces 361 C - Mike and Chocolate Thieves

    Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u   Description Bad ...

随机推荐

  1. C++ namespace功能总结

    案例背景:你写了一些代码,其中有一个函数名为xyz(),同时另一个可用库里也有一个同名的函数xyz(), 编译器没有办法知道你指的是哪个版本的xyz(). 解决办法:A namespace is de ...

  2. ebtables使用

    Targets: (1)ACCEPT : 让帧通过 (2)DROP: 丢弃帧. (3)CONTINUE:让帧继续走下面的规则(rule) (4)RETURN: 停止当前链的过滤规则,进而去走前面链的下 ...

  3. UVA 624 CD (01背包)

    //路径记录方法:若是dp[j-value[i]]+value[i]>dp[j]说明拿了这个东西,标志为1, //for循环标志,发现是1,就打印出来,并把背包的容量减少,再在次容量中寻找标志: ...

  4. 倒叙筛除list

    for(int i=list.Count-1;i>=0;i--) {    if(list[i])   {     list.RemoveAt(i);   } }

  5. 小菜鸟安装CocoaPods

    刚来到公司,以前没有用过CocoaPods. 参考的以下两篇文章,都是转载的. 第一篇比较偏技术性,叫做<Mac下CocoaPods安装步骤> http://blog.csdn.net/a ...

  6. NYOJ-915 +-字符串(贪心)

    +-字符串 时间限制:1000 ms  |  内存限制:65535 KB 难度:1   描述 Shiva得到了两个只有加号和减号的字符串,字串长度相同.Shiva一次可以把一个加号和它相邻的减号交换. ...

  7. android 编译的原理介绍

    http://blog.csdn.net/mr_raptor/article/details/7540066

  8. JSONModel解析数据成Model

    转自:http://blog.csdn.net/smking/article/details/40432287 JSONModel, Mantle 这两个开源库都是用来进行封装JSON->Mod ...

  9. ACE_Event_Handler:事件响应入口

    1:ACE_Event_Handler类 头文件“Event_Handler.h” 在ACE Reactor框架中,ACE_Event_Handler是所有事件处理器的基类.ACE_Event_Han ...

  10. JavaScript(6)——事件1.0

    ---恢复内容开始--- 事件 好不容易回到正轨,好好学习,天天向上.今天写的是事件,感觉内容蛮多的,所以分了两篇写,主要写了事件流.事件处理程序.事件对象.恩,明天还会再有一篇,哈哈哈.我努力的!我 ...