#include using namespace std; #define ill __int128 #define ll long long ll get_log(ll x){ ll cnt=1; ll res=0; while(cnt>=1; } return res; } ill solve(ll k){ ll res=ceil(powl(N,(long double)(1.0/k))); ll l=1,r=res,t=res; ill resl=(ill)res*k; for(ll p=1;p<=k;p++){ l=1,r=res; while(l<=r){ ll mid=(l+r)>>1 ; if(qpow(mid,p)*qpow(mid+1,k-p)>N){ r=mid-1; t=mid; }else{ l=mid+1; } } resl=(resl(ax-ay)*k+ay*solve(k) ? (ax-ay)*k+ay*solve(k) : ans); } while(ans){ ans1[++len]=ans%10; ans/=10; } for(int i=len;i>=1;i--){ printf("%d",ans1[i]); } return 0; }