#include using namespace std; #include #include namespace mp = boost::multiprecision; // 任意長整数型 using Bint = mp::cpp_int; // 仮数部が10進数で1024桁の浮動小数点数型(TLEしたら小さくする) using Real = mp::number>; Bint mypow(Bint x,Bint n){ Bint res=1; while(n>0){ if(n&1){ res=res*x; } x=x*x; n>>=1; } return res; } int main(){ Bint N; cin>>N; Bint ans=N; Bint j=2; while(mypow(2,j)<=N){ Bint left=0,right=N+10; while(right-left>1){ Bint mid=left+(right-left)/2; if(mypow(mid,j)>N){ right=mid; }else{ left=mid; } } ans=min(ans,left+j+N-mypow(left,j)); j++; } cout<