题目链接:

C. Mike and Chocolate Thieves

time limit per test

2 seconds

memory limit per test

256 megabytes

input

standard input

output

standard output

Bad news came to Mike's village, some thieves stole a bunch of chocolates from the local factory! Horrible!

Aside from loving sweet things, thieves from this area are known to be very greedy. So after a thief takes his number of chocolates for himself, the next thief will take exactly k times more than the previous one. The value of k (k > 1) is a secret integer known only to them. It is also known that each thief's bag can carry at most n chocolates (if they intend to take more, the deal is cancelled) and that there were exactly four thieves involved.

Sadly, only the thieves know the value of n, but rumours say that the numbers of ways they could have taken the chocolates (for a fixedn, but not fixed k) is m. Two ways are considered different if one of the thieves (they should be numbered in the order they take chocolates) took different number of chocolates in them.

Mike want to track the thieves down, so he wants to know what their bags are and value of n will help him in that. Please find the smallest possible value of n or tell him that the rumors are false and there is no such n.

 
Input
 

The single line of input contains the integer m (1 ≤ m ≤ 1015) — the number of ways the thieves might steal the chocolates, as rumours say.

 
Output
 

Print the only integer n — the maximum amount of chocolates that thieves' bags can carry. If there are more than one n satisfying the rumors, print the smallest one.

If there is no such n for a false-rumoured m, print  - 1.

 
Examples
 
input
1
output
8
input
8
output
54
input
10
output
-1

题意:

现在有四个小偷,第一个小偷偷走x,第二个x*k,三个x*k*k,四个x*k*k*k;
现在知道一共有n种偷法,问小偷的背包的最小容量是多少; 思路: 二分最小容量,check看这个数能否有n种偷法; AC代码:
//#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include <queue>
#include <cmath>
#include <map>
#include <cstring>
#include <algorithm>
#include <cstdio> using namespace std;
#define For(i,j,n) for(int i=j;i<=n;i++)
#define Riep(n) for(int i=1;i<=n;i++)
#define Riop(n) for(int i=0;i<n;i++)
#define Rjep(n) for(int j=1;j<=n;j++)
#define Rjop(n) for(int j=0;j<n;j++)
#define mst(ss,b) memset(ss,b,sizeof(ss));
typedef long long LL;
template<class T> void read(T&num) {
char CH; bool F=false;
for(CH=getchar();CH<''||CH>'';F= CH=='-',CH=getchar());
for(num=;CH>=''&&CH<='';num=num*+CH-'',CH=getchar());
F && (num=-num);
}
int stk[], tp;
template<class T> inline void print(T p) {
if(!p) { puts(""); return; }
while(p) stk[++ tp] = p%, p/=;
while(tp) putchar(stk[tp--] + '');
putchar('\n');
} const LL mod=1e9+;
const double PI=acos(-1.0);
const LL inf=1e18;
const int N=2e5+;
const int maxn=;
const double eps=1e-; LL m,dp[*N]; int check(LL x)
{
LL num=;
for(int i=;i<;i++)
{
if(dp[i]<=x)
{
num+=x/dp[i];
}
}
if(num>m)return ;
else if(num==m)return ;
return ;
}
void Init()
{
for(int i=;i<=;i++)
{
LL temp=i;
dp[i]=temp*temp*temp;
}
}
int main()
{
Init();
read(m);
LL l=,r=inf;
while(l<=r)
{
LL mid=(l+r)>>;
if(!check(mid))l=mid+;
else r=mid-;
}
if(check(l)==)cout<<l<<"\n";
else cout<<"-1"<<"\n";
return ;
}

codeforces 689C C. 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 Round #361 (Div. 2) C. Mike and Chocolate Thieves 二分

    C. Mike and Chocolate Thieves 题目连接: http://www.codeforces.com/contest/689/problem/C Description Bad ...

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

  4. 689C - Mike and Chocolate Thieves 二分

    题目大意:有四个小偷,第一个小偷偷a个巧克力,后面几个小偷依次偷a*k,a*k*k,a*k*k*k个巧克力,现在知道小偷有n中偷法,求在这n种偷法中偷得最多的小偷的所偷的最小值. 题目思路:二分查找偷 ...

  5. codeforces 361 C - Mike and Chocolate Thieves

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

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

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

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

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

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

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

  9. CodeForces 689C  Mike and Chocolate Thieves

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

随机推荐

  1. 遇到的Ajax相关问题

  2. HDU 5487 Difference of Languages

    Difference of Languages Time Limit: 1000ms Memory Limit: 32768KB This problem will be judged on HDU. ...

  3. 服务器端架构及实战 — C#分享

    简介 此文是我2008年读研究生期间做的C#项目技术分享,给计算机专业学生的一些经验分享. 当时工作2年后读研. 计算机基础了解及介绍 了解计算机的核心课程和大家的理解 二进制的历史和原理 数字逻辑及 ...

  4. 对于2-sat问题的求解

    一.O(n+m) 暴力不多说 二.O(m) 1.构图 2.求图的极大强连通子图 3.把每个子图收缩成单个节点,根据原图关系构造一个有向无环图 4.判断是否有解,无解则输出(退出) 5.对新图进行拓扑排 ...

  5. hdu 3940

    #include<stdio.h> #include<math.h> #include<string.h> double first(double vx,doubl ...

  6. 《TCP/IP详解卷1:协议》——第3章 IP:网际协议(转载)

    1.引言 IP是TCP/IP协议族中最核心的协议.所有的TCP.UDP.ICMP及IGMP数据都以IP数据报格式传输.IP提供不可靠. 无连接的数据报传送服务. (1)不可靠 它不能保证IP数据报能成 ...

  7. 小米自动砸蛋机器js代码

    02 //地址:http://static.xiaomi.cn/515 03 //@author:liuzh 04 //@url:http://blog.csdn.net/isea533 05 var ...

  8. FusionCharts for Flex 如何更改图表数据

    FusionCharts allows to change chart data and re-render the chart, after it has loaded on the user’s ...

  9. FATE---hdu2159(二重背包)

    FATE Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submis ...

  10. vm 安装CentOS7

    1.首先需要到CentOS官网下载CentOS7的iso镜像文件,地址http://mirrors.cn99.com/centos/7/isos/x86_64/ 这里我选择的是迅雷种子文件 2.下载完 ...