結果

問題 No.1664 Unstable f(n)
ユーザー 👑 CleyL
提出日時 2022-08-27 22:58:33
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 20 ms / 2,000 ms
コード長 470 bytes
コンパイル時間 1,055 ms
コンパイル使用メモリ 78,268 KB
最終ジャッジ日時 2025-01-31 06:34:33
ジャッジサーバーID
(参考情報)
judge4 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 38
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>

#include <cmath>
using namespace std;
int main(){
    long long a;cin>>a;
    long long ans = min(a,(long long)sqrt(a)+2+a-(long long)sqrt(a)*(long long)sqrt(a));
    for(long long i = 2; 1000001 > i; i++){
        long long nw = 1;
        for(int j = 0; a >= nw; j++){
            if(ans == -1)ans = i+j+a-nw;
            else ans = min(ans,i+j+a-nw);
            if(a/i < nw)break;
            nw *= i;
        }
    }
    cout << ans << endl;
}
0