結果
問題 | No.1664 Unstable f(n) |
ユーザー |
![]() |
提出日時 | 2023-06-07 22:52:47 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 760 bytes |
コンパイル時間 | 906 ms |
コンパイル使用メモリ | 104,268 KB |
最終ジャッジ日時 | 2025-02-13 23:17:48 |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 38 |
ソースコード
#include <iostream> #include <vector> #include <cmath> #include <map> #include <set> #include <iomanip> #include <queue> #include <algorithm> #include <numeric> #include <deque> #include <complex> #include <cassert> using namespace std; using ll = long long; ll n; bool f(ll i, ll j){ ll m=1; for (int k=0; k<j; k++){ if (m >= n/i+1) return 0; m *= i; } return 1; } int main(){ ll ans; cin >> n; ans = n; for (int j=1; j<=60; j++){ ll l=1, r=n+1, c; while(r-l>1){\ c = (l+r)/2; if (f(c, j)) l=c; else r=c; } ll m=1; for (int k=0; k<j; k++) m *= l; ans = min(ans, l+j+n-m); } cout << ans << endl; return 0; }