whust 2016 warm up G ||codeforces 689C. Mike and Chocolate Thieves
题意:给出一个m。。问恰好使得不超过某个n的a*b^3(a,b是正整数)的方案数为m的n是多少。。。
思路:暴力+二分。。。
1/* ***********************************************
2Author :111qqz
3Created Time :2016年07月18日 星期一 15时58分55秒
4File Name :code/2016whust/G.cpp
5************************************************ */
6
7#include <cstdio>
8#include <cstring>
9#include <iostream>
10#include <algorithm>
11#include <vector>
12#include <queue>
13#include <set>
14#include <map>
15#include <string>
16#include <cmath>
17#include <cstdlib>
18#include <ctime>
19#define fst first
20#define sec second
21#define lson l,m,rt<<1
22#define rson m+1,r,rt<<1|1
23#define ms(a,x) memset(a,x,sizeof(a))
24typedef long long LL;
25#define pi pair < int ,int >
26#define MP make_pair
27
28using namespace std;
29const double eps = 1E-8;
30const int dx4[4]={1,0,0,-1};
31const int dy4[4]={0,-1,1,0};
32const int inf = 0x3f3f3f3f;
33LL m,n;
34LL ans;
35LL cal( LL x)
36{
37 LL res = 0LL;
38 for ( LL i =2 ; i * i * i <= x ; i++)
39 res+=x/(i*i*i);
40 return res;
41}
42int main()
43{
44 #ifndef ONLINE_JUDGE
45 freopen("code/in.txt","r",stdin);
46 #endif
47
48 cin>>m;
49 n = 0 ;
50
51 LL cur = 1LL<<60;
52// cout<<"cur:"<<cur<<endl;
53 while (cur!=0LL)
54 {
55 LL tmp = cal(n+cur);
56 if (tmp<m) n +=cur;
57
58 cur >>=1LL;
59 }
60 n++;
61// cout<<" n:"<<n<<endl;
62 if (cal(n)!=m) ans = -1;
63 else ans = n;
64
65 cout<<ans<<endl;
66
67
68 #ifndef ONLINE_JUDGE
69 fclose(stdin);
70 #endif
71 return 0;
72}