結果

問題 No.1176 少ない質問
ユーザー ぷらぷら
提出日時 2020-08-21 22:03:42
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 787 bytes
コンパイル時間 1,519 ms
コンパイル使用メモリ 162,588 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-23 05:53:29
合計ジャッジ時間 2,241 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 1 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 2 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 2 ms
5,376 KB
testcase_15 AC 2 ms
5,376 KB
testcase_16 AC 1 ms
5,376 KB
testcase_17 AC 1 ms
5,376 KB
testcase_18 AC 2 ms
5,376 KB
testcase_19 AC 2 ms
5,376 KB
testcase_20 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e16+7;
int mod = 1e9+7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
signed main() {
    int A;
    cin >> A;
    int N = A;
    int ans = INF;
    int cnt = 0;
    int pow = 1;
    while (true) {
        cnt++;
        if((N+1)/2 <= pow) {
            break;
        }
        pow*=2;
    }
    ans = min(ans,2*cnt);
    cnt = 0;
    pow = 1;
    N = A;
    while (true) {
        cnt++;
        if((N+2)/3 <= pow) {
            break;
        }
        pow*=3;
    }
    ans = min(ans,3*cnt);
    cnt = 0;
    pow = 1;
    while (true) {
        cnt++;
        if((N+4)/5 <= pow) {
            break;
        }
        pow*=5;
    }
    cout << min(ans,5*cnt) << endl;
}

0