Title Link: http://acm.hust.edu.cn/vjudge/problem/visitOriginUrl.action?id=412145
Topic: Given a number n, ask whether it is possible to obtain a minimum integer x, so that in the 1-x range, you can take the N group of T*k^3<=x. T,k is an arbitrary integer that needs to be equal to N to t,k in case of less than equals x, so that it satisfies the t*k^3<=x. If x exists, then output x, if x does not exist, then output-1.
Problem Solving Ideas:
First Look at k=2, (1,2,4,8)/(2,4,8,16)/(3,6,12,24) ....
K=3, (1,3,9,27)/(2,6,18,54) ...
For a certain k, within the X range, the maximum number of groups that can be obtained is x/(k^3), because the number of legal groups is monotonic and can be solved by a two-part method.
Two situations are well understood, when the current quantity is greater than the required quantity, then move the right edge, when the current quantity is less than the required quantity, then move the left edge, but equal, and is not necessarily the solution. Because the title requirement is the smallest integer solution that is valid, the right boundary continues to move.
Problem Solving Code:
#include <cstdio>#include<iostream>using namespacestd;#definell Long Longll Solve (ll N) {ll ans=0; for(LL i=2;; i++) { if(n/(i*i*i) = =0) Break; Ans+=n/(i*i*i); } returnans;}intMain () {ll m; Cin>>m;intflag=0; ll L=1, r=5e15,ans; while(l<=R) {ll mid= (l+r)/2; Long LongCnt=solve (mid); if(cnt>m) r=mid-1; Else if(cnt<m) l=mid+1; Else{ans=mid; Flag=1; R=mid-1; }} printf ("%lld\n", flag?ans:-1); return 0;}
Codeforces 689C Mike and chocolate thieves