結果

問題 No.1152 10億ゲーム
ユーザー 👑 NachiaNachia
提出日時 2020-10-03 18:26:46
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 803 bytes
コンパイル時間 1,533 ms
コンパイル使用メモリ 164,420 KB
実行使用メモリ 24,456 KB
平均クエリ数 25.28
最終ジャッジ日時 2023-09-24 06:41:53
合計ジャッジ時間 8,115 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
23,784 KB
testcase_01 AC 66 ms
24,264 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 66 ms
23,772 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 65 ms
23,496 KB
testcase_09 AC 65 ms
24,012 KB
testcase_10 AC 66 ms
24,276 KB
testcase_11 AC 66 ms
23,472 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 65 ms
24,000 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 64 ms
23,496 KB
testcase_21 AC 65 ms
24,288 KB
testcase_22 AC 66 ms
23,628 KB
testcase_23 AC 66 ms
24,324 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 AC 66 ms
23,376 KB
testcase_39 AC 66 ms
23,796 KB
testcase_40 AC 67 ms
23,376 KB
testcase_41 AC 66 ms
23,928 KB
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
testcase_45 WA -
testcase_46 AC 66 ms
23,976 KB
testcase_47 AC 66 ms
23,628 KB
testcase_48 AC 66 ms
24,288 KB
testcase_49 AC 66 ms
23,616 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
#define rep(i,n) for(int i=0; i<(n); i++)

pair<int, int> g(int x) {
    pair<int, int> buf = { 0,0 };
    while (x % 2 == 0) { buf.first++; x /= 2; }
    while (x % 5 == 0) { buf.second++; x /= 5; }
    return buf;
}

int main() {
    int x, y; cin >> x >> y;

    while (true) {
        pair<int, int> px = g(x), py = g(y);
        if (abs(py.first - px.first) > abs(py.second - px.second)) {
            if (px.first < py.first) x *= 2;
            else x /= 2;
        }
        else {
            if (px.second < py.second) x *= 5;
            else x /= 5;
        }

        cout << x << endl;
        if (x == y) break;
        

        cin >> y;
        if (x == y) break;
    }

    return 0;
}
0