C. Mike and Chocolate Thieves

题目连接:

http://www.codeforces.com/contest/689/problem/C

Description

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 fixed n, 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.

Sample Input

8

Sample Output

54

Hint

题意

给你n,让你找到一个最小的数t,使得这个数t以内,恰好存在n个四元组

这个四元组需要满足 a,ak,ak2,ak3,且这四个数都小于等于t

题解

二分答案,然后我们暴力枚举k,然后算四元组有多少个就好了。

代码

#include<bits/stdc++.h>
using namespace std;
long long n;
long long mul(long long x){
return x*x*x;
}
long long cal(long long k){
long long sum = 0;
for(int i=2;i<=1e6;i++)
sum+=k/mul(i);
return sum;
}
int main(){
cin>>n;
long long l = 0,r = 1e18;
while(l<=r){
long long mid=(l+r)/2;
if(cal(mid)>=n)r=mid-1;
else l=mid+1;
}
if(cal(r+1)==n)cout<<r+1<<endl;
else cout<<"-1"<<endl;
}

最新文章

  1. SQL Server日期时间格式转换字符串详解 (详询请加qq:2085920154)
  2. jquery layer弹出层插件
  3. python基础(内置函数+文件操作+lambda)
  4. ubuntu下安装、启动和卸载SSH
  5. Windows 10:解决开机显示C:\WINDOWS\system32\config\systemprofile\Desktop不可用的方法
  6. asterisk
  7. Java中的hashCode 方法
  8. EGit插件安装(附Eclipse版本对应表)
  9. 绩效等级系统与MBO
  10. GCD之after
  11. oracle pl/sql 变量
  12. java二维码生成
  13. C#的多样性,new,sealed方法
  14. RBM:深度学习之Restricted Boltzmann Machine的BRBM学习+LR分类—Jason niu
  15. 5、SAMBA服务一:参数详解
  16. wait与sleep的区别
  17. topcoder srm 679 div1
  18. 100-days: Three
  19. python中交换两个值的方法
  20. es新增字段,并设置默认值

热门文章

  1. DevExpress 行事历(Scheduler)的常用属性、事件和方法
  2. p,br,hn,b,i,u,s,sup,sub标签
  3. jQuery-对标签元素 文本操作-属性操作-文档的操作
  4. Windows版Oracle重建EM---备注
  5. js实现ctrl+v粘贴图片或是截图
  6. SQLAlchemy-介绍安装
  7. Little C Loves 3 I
  8. 16/11/22_plsql
  9. 【转】Android开启网络调试的方法
  10. day7 socket网络编程基础