結果

問題 No.1664 Unstable f(n)
ユーザー 風月風月
提出日時 2021-09-03 21:44:20
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,017 bytes
コンパイル時間 1,653 ms
コンパイル使用メモリ 166,804 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-05-09 02:51:49
合計ジャッジ時間 11,608 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<bits/stdc++.h>
#include<unordered_map>
#define for_int(i,a,b) for(int i=(a);i<=(b);++i)
#define rep_int(i,a,b) for(int i=(a);i>=(b);--i)
#define for_ll(i,a,b) for(ll i=(a);i<=(b);++i)
#define rep_ll(i,a,b) for(ll i=(a);i>=(b);--i)
#define Ios std::ios::sync_with_stdio(false),std::cin.tie(0)
#define ull unsigned long long
#define ll long long
#define db double
#define PII std::pair<int,int>
#define PLI std::pair<long long , int>
template<class T> void chkmax(T& a, T b) { a > b ? (a = a) : (a = b); }
template<class T> void chkmin(T& a, T b) { a > b ? (a = b) : (a = a); }
template<class T> T min(T a, T b) { return a > b ? b : a; }
template<class T> T max(T a, T b) { return a < b ? b : a; }
template<class T> T abs(T a) { return a < 0 ? -a : a; }
//using namespace std;
/*
    1.注意边界情况
    2.优先考虑时间复杂度
!!! 3.求最大值时,答案应至多初始化为INT_MIN;求最小值时,答案应至少初始化为INT_MAX
    4.遇事不决先暴力
    5.代码要写简洁
    6.计数题要开long long
*/
//快速IO
template<class T>
inline bool rd(T& ret) {
    char c; int sgn;
    if (c = getchar(), c == EOF) return 0;
    while (c != '-' && (c < '0' || c > '9')) c = getchar();
    sgn = (c == '-') ? -1 : 1;
    ret = (c == '-') ? 0 : (c - '0');
    while (c = getchar(), c >= '0' && c <= '9') ret = ret * 10 + (c - '0');
    ret *= sgn;
    return true;
}
template<class T>
inline void print(T x) {
    if (x > 9) print(x / 10);
    putchar(x % 10 + '0');
    return;
}
using std::vector;
using std::queue;
using std::string;
using std::map;
using std::unordered_map;
using std::priority_queue;
using std::cout;
using std::cin;


long long n;
long long res;
int main() {
    rd(n);
    res = n;
    for (int i = 2;i <= min(n , 20000000ll) ; ++i) {
        int k = log(n) / log(i);
        long long tmp = 1, cnt = n;
        for (int j = 1; j <= k; ++j) tmp *= i;
        cnt = n + k + i - tmp;
        chkmin(res, cnt);
    }
    print(res); puts("");
    return 0;
}
0