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

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

In the first sample case the smallest n that leads to exactly one way of stealing chocolates is n = 8, whereas the amounts of stealed chocolates are (1, 2, 4, 8) (the number of chocolates stolen by each of the thieves).

In the second sample case the smallest n that leads to exactly 8 ways is n = 54 with the possibilities:(1, 2, 4, 8),  (1, 3, 9, 27),  (2, 4, 8, 16),  (2, 6, 18, 54),  (3, 6, 12, 24),  (4, 8, 16, 32),  (5, 10, 20, 40),  (6, 12, 24, 48).

There is no n leading to exactly 10 ways of stealing chocolates in the third sample case.

思路:二分找小于等于这个数的个数;

#include<bits/stdc++.h>
using namespace std;
#define ll __int64
#define mod 100000007
#define esp 0.00000000001
const int N=1e5+,M=1e6+,inf=1e9;
ll num[M];
ll check(ll x)
{
ll ans=;
for(int i=;i<=;i++)
ans+=x/num[i];
return ans;
}
int main()
{
ll x,y,z,i,t;
for(i=;i<=;i++)
num[i]=i*i*i;
scanf("%I64d",&x);
ll st=;
ll en=1e16;
ll mid;
while(st<en)
{
mid=(st+en)>>;
ll flag=check(mid);
if(flag<x)
st=mid+;
else
en=mid;
}
if(check(st)==x)
printf("%I64d\n",st);
else
printf("-1\n");
return ;
}

Codeforces Round #341 (Div. 2) C. Mike and Chocolate Thieves 二分的更多相关文章

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

  2. set+线段树 Codeforces Round #305 (Div. 2) D. Mike and Feet

    题目传送门 /* 题意:对于长度为x的子序列,每个序列存放为最小值,输出长度为x的子序列的最大值 set+线段树:线段树每个结点存放长度为rt的最大值,更新:先升序排序,逐个添加到set中 查找左右相 ...

  3. 数论/暴力 Codeforces Round #305 (Div. 2) C. Mike and Frog

    题目传送门 /* 数论/暴力:找出第一次到a1,a2的次数,再找到完整周期p1,p2,然后以2*m为范围 t1,t2为各自起点开始“赛跑”,谁落后谁加一个周期,等到t1 == t2结束 详细解释:ht ...

  4. 暴力 Codeforces Round #305 (Div. 2) B. Mike and Fun

    题目传送门 /* 暴力:每次更新该行的num[],然后暴力找出最优解就可以了:) */ #include <cstdio> #include <cstring> #includ ...

  5. 字符串处理 Codeforces Round #305 (Div. 2) A. Mike and Fax

    题目传送门 /* 字符串处理:回文串是串联的,一个一个判断 */ #include <cstdio> #include <cstring> #include <iostr ...

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

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

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

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

  8. Codeforces Round #305 (Div. 2) B. Mike and Fun 暴力

     B. Mike and Fun Time Limit: 20 Sec  Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/548/pro ...

  9. Codeforces Round #410 (Div. 2)C. Mike and gcd problem

    题目连接:http://codeforces.com/contest/798/problem/C C. Mike and gcd problem time limit per test 2 secon ...

随机推荐

  1. MySQL 一些让人容易忽视的知识点

    一下都是MySQL在实际开发中,经常容易让人忽视的点,希望对您有帮助,帮您越过这些坑. 一:MySQL AND优先级大于OR 今天上班时在写一个业务的时候又发现了一个MySQL的问题: 我们的业务是这 ...

  2. Git Extension工具安装及使用

    以下界面所示的三个工具,如果没安装过,则勾上让其安装.MsysGit为Git的Windows版本,必须要安装:Kdiff为对比/合并工具,可选安装,可以换为使用其它的相关工具:最后一个Windows ...

  3. SDUT3141:Count(哈希)好题

    题目:传送门 题目描述 You are given an integer array s[] and are asked to count how many positions a, b, c and ...

  4. Excel文本型数据转为数值型的方法

    操作步骤非常简单,适用于所有版本的Excel. 在任意一个空白单元格中输入数值1,然后选中该单元格,执行复制操作: 选中需要转换的单元格(或区域),执行“编辑.选择性粘贴”命令,打开“选择性粘贴”对话 ...

  5. 查看Oracle latch _spin_count默认值

    查看Oracle latch  _spin_count默认值 SELECT X.KSPPINM NAME, Y.KSPFTCTXVL VALUE, Y.KSPFTCTXDF ISDEFAULT FRO ...

  6. Deep learning与Neural Network

    深度学习是机器学习研究中的一个新的领域,其动机在于建立.模拟人脑进行分析学习的神经网络,它模仿人脑的机制来解释数据,例如图像,声音和文本.深度学习是无监督学习的一种. 深度学习的概念源于人工神经网络的 ...

  7. HTML5游戏开发系列教程4(译)

    原文地址:http://www.script-tutorials.com/html5-game-development-lesson-4/ 这篇文章是我们继续使用canvas来进行HTML5游戏开发系 ...

  8. discuz debug下载地址

      Discuz!X会自带Debug模式,主要是用于排查性能问题.垃圾站建议当如果您的站点调试完之后,一定要把debug模式关闭,以免其他用户会获取到一些敏感信息.在调试过程中,config文件配置的 ...

  9. JS传参中文乱码问题.NET

    前台js代码 window.location.href = "/product.aspx?id=2&title=" +encodeURIComponent(strtitle ...

  10. PKU 1655 Balancing Act(树+树的重心)

    #include<cstdio> #include<cstring> #include<algorithm> #define maxn 20005 using na ...