結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 57 ms
23,388 KB
testcase_01 AC 51 ms
23,376 KB
testcase_02 RE -
testcase_03 RE -
testcase_04 AC 52 ms
23,976 KB
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 AC 52 ms
23,328 KB
testcase_09 AC 52 ms
23,640 KB
testcase_10 AC 52 ms
24,120 KB
testcase_11 RE -
testcase_12 WA -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 AC 55 ms
23,592 KB
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 AC 53 ms
23,760 KB
testcase_21 AC 54 ms
23,412 KB
testcase_22 AC 52 ms
23,772 KB
testcase_23 AC 52 ms
23,412 KB
testcase_24 WA -
testcase_25 RE -
testcase_26 WA -
testcase_27 WA -
testcase_28 RE -
testcase_29 RE -
testcase_30 RE -
testcase_31 RE -
testcase_32 RE -
testcase_33 RE -
testcase_34 RE -
testcase_35 RE -
testcase_36 WA -
testcase_37 WA -
testcase_38 RE -
testcase_39 RE -
testcase_40 RE -
testcase_41 RE -
testcase_42 RE -
testcase_43 RE -
testcase_44 WA -
testcase_45 WA -
testcase_46 RE -
testcase_47 RE -
testcase_48 AC 54 ms
24,120 KB
testcase_49 AC 60 ms
23,760 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 and p1.first < 9) p1.first++;
            else if (p1.second <= p2.second and p1.second < 9) p1.second++;
            else if (p1.second - 2 > p2.second) p1.second--;
            else if (p1.first - 2 > p2.first) p1.first--;
            else exit(8);
        }
        
        cnt++;
        if (cnt >= 36) return 0;
        cout << val(p1) << endl;
        if (p1 == p2) return 0;
        int x;
        cin >> x;
        p2 = fac(x);
    }
}
0