結果

問題 No.1664 Unstable f(n)
ユーザー ktr216
提出日時 2021-09-03 21:39:54
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 14 ms / 2,000 ms
コード長 432 bytes
コンパイル時間 1,522 ms
コンパイル使用メモリ 167,220 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-12-15 11:09:31
合計ジャッジ時間 3,180 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 38
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i, l, r) for (int i = (l); i < (r); i++)
using namespace std;

typedef long long ll;

int main() {
    ll n;
    cin >> n;
    ll ans = n;
    ll s = sqrt(n);
    ans = min(ans, s + 2 + n - s * s);
    rep(i, 2, 1000001) {
        ll x = 1, y = 0;
        while (x <= n / i) {
            x *= i;
            y++;
        }
        ans = min(ans, i + y + n - x);
    }
    cout << ans << endl;
}
0