题目链接:

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. python和shell获取命令行参数的区别

    一.命令行参数的取得对于一些功能性的脚本来说非常有用,不至于将功能写死在脚本中. shell的命令行参数直接用 $ 1,$2 等就可以直接获取 其中 $1 表示 第二个参数,即命令行的第一个参数,因为 ...

  2. BNUOJ 1575 Supermarket

    Supermarket Time Limit: 2000ms Memory Limit: 65536KB This problem will be judged on PKU. Original ID ...

  3. Kubernetes网络设计原则

    在配置集群网络插件或者实践K8S 应用/服务部署请时刻想到这些原则: 1.每个Pod都拥有一个独立IP地址,Pod内所有容器共享一个网络命名空间 2.集群内所有Pod都在一个直接连通的扁平网络中,可通 ...

  4. 【shell】通过shell编写ping包及arp的监控并发送短信

    1 #!/bin/bash 2 NOW="`date +%Y%m%d-%H:%M:%S`" 3 PHONES=15134567893 4 IP=10.100.8.78 5 GATE ...

  5. [HDU3062]Party(2-sat)

    传送门 2-sat问题,只需要判断yes或no 所以可以直接连边,缩点,判断同一组的是否在同一个块中. #include <cstdio> #include <stack> # ...

  6. OpenJudge 6042 雇佣兵

    37:雇佣兵 提问 总时间限制:  1000ms 内存限制:  65536kB 描述 雇佣兵的体力最大值为M,初始体力值为0.战斗力为N.拥有X个能量元素. 当雇佣兵的体力值恰好为M时,才可以参加一个 ...

  7. CSY版最大团,速度快一倍

    #include <bits/stdc++.h> using namespace std; #define REP(i, n) for(int i(0); i < (n); ++i) ...

  8. 寒武纪camp Day4

    补题进度:7/11 A(博弈论) 略 B 待填坑 C(贪心) 题意: 一个序列是good的当且仅当相邻两个数字不相同.给出一个长度为n的数列,每个数字是ai.定义一种操作就是把a中某个元素拿到首位去, ...

  9. java 定时备份数据库

    原文:http://www.open-open.com/code/view/1447490829678 /** 操作数据库 */ public class BackupDb { public Stri ...

  10. android多个fragment返回键层层返回

    在FragmentActivity的fragment跳转的时候加入到执行栈. public void switchFrag(BaseFragment to) { getSupportFragmentM ...