Test instructions: There are four thieves to steal chocolate, each small secret chocolate is the former thief K times. Example: A,ak,ak^2,ak^3. Then give your thief Head chocolate scheme number, Q: Under the conditions, the maximum amount of chocolate in the backpack is the minimum.
Analysis: Minimum maximum value. So two minutes n.
1 /************************************************2 Author:D Arktong3 Created TIME:2016/7/7 17:06:124 File name:c.cpp5 *************************************************/6 7#include <cstdio>8#include <cstring>9#include <iostream>Ten#include <algorithm> One#include <vector> A#include <queue> -#include <Set> -#include <map> the#include <string> -#include <cmath> -#include <cstdlib> -#include <ctime> + - #defineINF 0x3f3f3f3f + #defineESP 1e-9 AtypedefLong Longll; at using namespacestd; - ll M; - ll Check (ll x) - { -ll sum=0; - for(LL i=2;; ++i) in { - if(X<i*i*i) Break; tosum+=x/(i*i*i); + } - returnsum; the } * ll BS () $ {Panax Notoginsengll l=0, r=0x7fffffffffffffff; - ll T, Mid; the while(l<R) + { AMid = (l+r+1)/2; thet =Check (mid); + //cout<< "T:" <<t<< "L:" <<L<< "R:" <<R<<endl; - if(t==m) Break; $ Else if(t>m) r=mid-1; $ ElseL=mid+1; - } - if(t==m)returnmid; the Else return-1; - }Wuyi voidSolve (ll x) the { - //< cout<< "x:" <<x<<endl; Wu if(x==-1) puts ("-1"); - Else About { $ll Ma=0; - for(LL i=2;; ++i) - { - if(X<i*i*i) Break; AMA = Max (MA, (x/(i*i*i) *i*i*i)); + } thecout<<ma<<Endl; - } $ } the the the intMain () the { - //freopen ("In.txt", "R", stdin); in //freopen ("OUT.txt", "w", stdout); thescanf"%lld", &m); the Solve (BS ()); About return 0; the}
Codeforces 689c-mike and chocolate thieves