結果
問題 |
No.1664 Unstable f(n)
|
ユーザー |
|
提出日時 | 2021-09-18 18:25:13 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 658 bytes |
コンパイル時間 | 1,441 ms |
コンパイル使用メモリ | 168,256 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-06-30 16:12:13 |
合計ジャッジ時間 | 2,858 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 36 WA * 2 |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll=long long; ll mypow(ll x,ll n){ ll res=1; while(n>0){ if(n&1){ res=res*x; } x=x*x; n>>=1; } return res; } int main(){ ll N; cin>>N; ll ans=N; ll j=2; while(mypow(2,j)<=N){ ll left=0,right=pow(N,(long double)1/j)+10; while(right-left>1){ ll 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<<ans<<endl; return 0; }