結果

問題 No.1152 10億ゲーム
ユーザー 👑 hitonanodehitonanode
提出日時 2020-08-07 23:25:48
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,559 bytes
コンパイル時間 2,113 ms
コンパイル使用メモリ 201,300 KB
実行使用メモリ 24,408 KB
平均クエリ数 26.88
最終ジャッジ日時 2023-09-24 05:03:47
合計ジャッジ時間 7,874 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 58 ms
23,916 KB
testcase_01 AC 54 ms
23,628 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 56 ms
23,328 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 53 ms
23,352 KB
testcase_09 AC 56 ms
23,484 KB
testcase_10 AC 54 ms
23,748 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 53 ms
23,340 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 52 ms
23,616 KB
testcase_23 WA -
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 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
testcase_45 WA -
testcase_46 WA -
testcase_47 WA -
testcase_48 AC 52 ms
24,252 KB
testcase_49 AC 52 ms
23,496 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using pint = pair<int, int>;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define REP(i, n) FOR(i,0,n)
#define dbg(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ") " << __FILE__ << endl;

pint fac(int x)
{
    int i2 = 0, i5 = 0;
    while (x % 2 == 0) x /= 2, i2++;
    while (x % 5 == 0) x /= 5, i5++;
    return pint(i2, i5);
}

int val(pint p)
{
    int ret = 1;
    REP(_, p.first) ret *= 2;
    REP(_, p.second) ret *= 5;
    return ret;
}

int main()
{
    int x1, x2;
    cin >> x1 >> x2;
    pint p1 = fac(x1), p2 = fac(x2);
    int cnt = 0;
    while (true)
    {
        if (p1 == p2) return 0;
        int dist = abs(p1.first - p2.first) + abs(p1.second - p2.second);

        if (dist == 1) p1 = p2;
        else if (dist % 2 == 0)
        {
            if (p1 == pint(9, 9)) p1 = pint(7, 9);
            else if (p1 == pint(7, 9)) p1 = pint(9, 9);
            else if (p1.second < 9) p1.second++;
            else if (p1.first == 8) p1.first--;
            else p1.first++;
        }
        else
        {
            if (p1.first <= p2.first + 1 and p1.first < 9) p1.first++;
            else if (p1.second <= p2.second + 1 and p1.second < 9) p1.second++;
            else if (p1.second - p2.second > p1.first - p2.first) p1.second--;
            else p1.first--;
        }
        
        cnt++;
        if (cnt >= 36) return 0;
        cout << val(p1) << endl;
        if (p1 == p2) return 0;
        int x;
        cin >> x;
        p2 = fac(x);
    }
}
0