結果
問題 |
No.1664 Unstable f(n)
|
ユーザー |
![]() |
提出日時 | 2022-07-10 21:42:51 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 448 bytes |
コンパイル時間 | 2,990 ms |
コンパイル使用メモリ | 244,012 KB |
実行使用メモリ | 13,884 KB |
最終ジャッジ日時 | 2024-06-11 12:28:58 |
合計ジャッジ時間 | 6,485 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 8 TLE * 1 -- * 29 |
ソースコード
#include <bits/stdc++.h> using namespace std; #define int long long signed main(){ int N; cin>>N; int ans = N; int l = 0,r = 1e9+1; while(r-l > 1){ int mid = (l+r)/2; if(mid*mid > N) r = mid; else l = mid; } ans = min(ans,2+l+(N-l*l)); for(int i=2;i*i*i<=N;i++){ int now = 1; int count = 0; while(now*i <= N){ now *= i; count++; ans = min(ans,i+count+N-now); } } cout<<ans<<endl; }