SOURSE&NAME
Mike and Chocolate Thieves CodeForces - 689C
http://codeforces.com/problemset/problem/689/C
Sample Input
8
10
Sample Output
54
-1
题意
m种选择方式 问n的最小值
四个人 每个人都是前面的k倍 k > 1
罗列种类数 每种结尾均为 8 27 64…的倍数
n的最小值即为第四个人的值
题解:
二分枚举n 再枚举2到1e5 复杂度 1e5*log1e16
AC代码
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;
#define ll long long
int main(){
ll m; cin>>m;
ll l = 8,r = 8e16;
ll ans = -1;
while (l <= r){
ll mid = (l + r)>>1;
ll tep = 0;
for (ll i = 2; i*i*i <= mid; ++i){
tep += mid/(i*i*i);
}
if (tep == m) ans = mid;
if (tep >= m) r = mid - 1;
else l = mid + 1;
}
printf("%lld\n", ans);
return 0;
}