#include using namespace std; #include #include #include #include #include template inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } #define rep(i,n) for (int i = 0; i < (n); ++i) typedef long long ll; typedef long double ld; using P=pair; const ld INF=1e18; const int mod=1e9+7; void solve(){ ll n; cin>>n; ll x=sqrt(n); ll y=1,ans=1e18; for(ll i=0;y<=n;i++){ ll k=n-y; chmin(ans,x+i+k); if(y*x>n){break;} y*=x; } cout<