結果

問題 No.1664 Unstable f(n)
ユーザー abc3abc3
提出日時 2021-09-03 21:41:49
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 935 bytes
コンパイル時間 2,317 ms
コンパイル使用メモリ 201,984 KB
実行使用メモリ 13,764 KB
最終ジャッジ日時 2024-05-09 02:42:29
合計ジャッジ時間 6,283 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 TLE -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

    #include <bits/stdc++.h>
    using namespace std;
    #include <math.h>
    #include <iomanip>
    #include <cstdint>
    #include <string>
    #include <sstream>
    template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
    template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
    #define rep(i,n) for (int i = 0; i < (n); ++i)
    typedef long long ll;
    typedef long double ld;
    using P=pair<ll,ll>;
    const ld INF=1e18;
    const int mod=1e9+7;
    
    void solve(){
        ll n;
        cin>>n;
        ll x=sqrt(n);
        ll y=1,ans=1e18;
        for(ll i=0;y<=n;y*=x){
            ll k=n-y;
            chmin(ans,x+i+k);
            if(y>n/x){break;}
        }
        cout<<ans<<endl;
    }  

    int main(){
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        
        solve();
        
        return 0;
    }
0