結果

問題 No.1152 10億ゲーム
ユーザー keijakkeijak
提出日時 2021-04-30 18:35:11
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 85 ms / 2,000 ms
コード長 1,424 bytes
コンパイル時間 235 ms
コンパイル使用メモリ 10,972 KB
実行使用メモリ 24,772 KB
平均クエリ数 25.06
最終ジャッジ日時 2023-09-24 10:30:24
合計ジャッジ時間 7,957 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 83 ms
24,092 KB
testcase_01 AC 82 ms
24,172 KB
testcase_02 AC 84 ms
24,760 KB
testcase_03 AC 84 ms
23,972 KB
testcase_04 AC 82 ms
23,948 KB
testcase_05 AC 84 ms
24,484 KB
testcase_06 AC 84 ms
24,108 KB
testcase_07 AC 84 ms
24,188 KB
testcase_08 AC 82 ms
24,656 KB
testcase_09 AC 82 ms
23,968 KB
testcase_10 AC 83 ms
24,044 KB
testcase_11 AC 85 ms
24,400 KB
testcase_12 AC 84 ms
24,552 KB
testcase_13 AC 85 ms
23,924 KB
testcase_14 AC 83 ms
24,460 KB
testcase_15 AC 82 ms
24,104 KB
testcase_16 AC 82 ms
24,248 KB
testcase_17 AC 85 ms
23,948 KB
testcase_18 AC 84 ms
24,004 KB
testcase_19 AC 83 ms
24,700 KB
testcase_20 AC 83 ms
24,448 KB
testcase_21 AC 84 ms
24,176 KB
testcase_22 AC 83 ms
23,996 KB
testcase_23 AC 84 ms
24,228 KB
testcase_24 AC 83 ms
24,028 KB
testcase_25 AC 82 ms
24,584 KB
testcase_26 AC 84 ms
24,152 KB
testcase_27 AC 83 ms
24,668 KB
testcase_28 AC 83 ms
24,488 KB
testcase_29 AC 83 ms
24,480 KB
testcase_30 AC 83 ms
24,024 KB
testcase_31 AC 84 ms
24,108 KB
testcase_32 AC 84 ms
24,408 KB
testcase_33 AC 84 ms
24,068 KB
testcase_34 AC 84 ms
24,196 KB
testcase_35 AC 83 ms
24,548 KB
testcase_36 AC 84 ms
24,200 KB
testcase_37 AC 83 ms
24,720 KB
testcase_38 AC 82 ms
24,256 KB
testcase_39 AC 82 ms
24,532 KB
testcase_40 AC 83 ms
24,064 KB
testcase_41 AC 82 ms
24,772 KB
testcase_42 AC 83 ms
24,224 KB
testcase_43 AC 83 ms
24,684 KB
testcase_44 AC 84 ms
24,200 KB
testcase_45 AC 83 ms
24,188 KB
testcase_46 AC 82 ms
24,132 KB
testcase_47 AC 82 ms
24,732 KB
testcase_48 AC 82 ms
24,640 KB
testcase_49 AC 83 ms
24,328 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys


def decode(x):
    c2, c5 = 0, 0
    while x % 2 == 0:
        c2 += 1
        x //= 2
    while x % 5 == 0:
        c5 += 1
        x //= 5
    assert x == 1
    return [c2, c5]


def encode(p):
    c2, c5 = p
    x = 1
    for i in range(c2):
        x *= 2
    for i in range(c5):
        x *= 5
    return x


x1, x2 = [int(x) for x in input().split()]
p1 = decode(x1)
p2 = decode(x2)

P = 2 ** 7 * 5 ** 9
while x1 != P:
    if p1[0] > 7:
        p1[0] -= 1
    elif p1[0] < 7:
        p1[0] += 1
    elif p1[1] < 9:
        p1[1] += 1
    else:
        assert False
    x1 = encode(p1)
    print(x1, flush=True)
    if x1 == x2:
        exit(0)
    x2 = int(input())
    if x1 == x2:
        exit(0)
    p2 = decode(x2)

if x2 > x1:
    print(x2, flush=True)
    exit(0)

if (p1[0] + p1[1]) % 2 == (p2[0] + p2[1]) % 2:
    p1[0] += 2
    x1 = 10 ** 9
    print(x1, flush=True)
    if x1 == x2:
        exit(0)
    x2 = int(input())
    if x1 == x2:
        exit(0)
    p2 = decode(x2)

while True:
    d2 = abs(p1[0] - p2[0])
    d5 = abs(p1[1] - p2[1])
    if d2 < d5:
        if p1[1] > p2[1]:
            p1[1] -= 1
        else:
            p1[1] += 1
    else:
        if p1[0] > p2[0]:
            p1[0] -= 1
        else:
            p1[0] += 1
    x1 = encode(p1)
    print(x1, flush=True)
    if x1 == x2:
        exit(0)
    x2 = int(input())
    if x1 == x2:
        exit(0)
    p2 = decode(x2)
0