标签:
题目并不难,就是比赛的时候没敢去二分,也算是一个告诫,应该敢于思考……
#include<stdio.h> #include<iostream> using namespace std; int main() { long long n; scanf("%I64d",&n); long long left=1,right=1e18,mid,num,m,s; long long ans=-1; while(left<=right) { mid=(left+right)>>1; num = 0; for(long long i=2;i <= 1000000; i++) { m = i*i*i; s=mid/m; num+=s; if(s==0)break; } if(num==n) ans=mid; if(num>=n) { right=mid-1; } else { left=mid+1; } } printf("%I64d\n",ans); }
CodeForces 689C Mike and Chocolate Thieves (二分最大化最小值)
标签:
原文地址:http://www.cnblogs.com/jifahu/p/5773794.html