結果

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

ソースコード

diff #

#include <iostream>
#include <cmath>
using namespace std;
int main(){
    long long a;cin>>a;
    long long ans =(long long)sqrt(a)+2+a-(long long)sqrt(a)*(long long)sqrt(a);
    for(int 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);
            nw *= i;
        }
    }
    cout << ans << endl;
}
0