結果

問題 No.1152 10億ゲーム
ユーザー vwxyzvwxyz
提出日時 2023-12-21 03:21:00
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
RE  
実行時間 -
コード長 1,620 bytes
コンパイル時間 119 ms
コンパイル使用メモリ 12,032 KB
実行使用メモリ 26,248 KB
平均クエリ数 27.28
最終ジャッジ日時 2023-12-21 03:21:09
合計ジャッジ時間 9,049 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 119 ms
26,248 KB
testcase_01 AC 115 ms
26,248 KB
testcase_02 AC 114 ms
26,248 KB
testcase_03 AC 112 ms
26,248 KB
testcase_04 AC 111 ms
26,248 KB
testcase_05 AC 110 ms
26,248 KB
testcase_06 AC 114 ms
26,248 KB
testcase_07 AC 114 ms
26,248 KB
testcase_08 AC 110 ms
26,248 KB
testcase_09 AC 111 ms
26,248 KB
testcase_10 AC 127 ms
26,248 KB
testcase_11 AC 114 ms
26,248 KB
testcase_12 RE -
testcase_13 RE -
testcase_14 AC 113 ms
26,248 KB
testcase_15 AC 113 ms
26,248 KB
testcase_16 AC 109 ms
26,248 KB
testcase_17 AC 110 ms
26,248 KB
testcase_18 AC 113 ms
26,248 KB
testcase_19 AC 112 ms
26,248 KB
testcase_20 AC 113 ms
26,248 KB
testcase_21 AC 113 ms
26,248 KB
testcase_22 AC 112 ms
26,248 KB
testcase_23 AC 110 ms
26,248 KB
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 RE -
testcase_30 RE -
testcase_31 RE -
testcase_32 RE -
testcase_33 RE -
testcase_34 AC 119 ms
26,248 KB
testcase_35 AC 117 ms
26,248 KB
testcase_36 AC 116 ms
26,248 KB
testcase_37 AC 115 ms
26,248 KB
testcase_38 AC 112 ms
26,248 KB
testcase_39 AC 113 ms
26,248 KB
testcase_40 AC 112 ms
26,248 KB
testcase_41 AC 112 ms
26,248 KB
testcase_42 RE -
testcase_43 RE -
testcase_44 RE -
testcase_45 RE -
testcase_46 AC 115 ms
26,248 KB
testcase_47 AC 114 ms
26,248 KB
testcase_48 AC 111 ms
26,248 KB
testcase_49 AC 110 ms
26,248 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def x_to_cnt(x):
    cnt2,cnt5=0,0
    while x%2==0:
        x//=2
        cnt2+=1
    while x%5==0:
        x//=5
        cnt5+=1
    return cnt2,cnt5
def cnt_to_x(cnt2,cnt5):
    return 2**cnt2*5**cnt5
x1,x2=map(int,input().split())
c12,c15=x_to_cnt(x1)
c22,c25=x_to_cnt(x2)
while (c12,c15)!=(7,9):
    if c12<7:
        x1*=2
        c12+=1
    elif c12>7:
        x1//=2
        c12-=1
    elif c15<9:
        x1*=5
        c15+=1
    elif c15>9:
        x1//=5
        c15-=1
    print(x1)
    if x1==x2:
        exit()
    x2=int(input())
    if x1==x2:
        exit()
assert x1==2**7*5**9
if (abs(c12-c22)+abs(c15-c25))%2==0:
    x1=10**9
    print(x1)
    if x1==x2:
        exit()
    x2=int(input())
    if x1==x2:
        exit()
else:
    if abs(c12-c22)+abs(c15-c25)==1:
        x1=x2
        print(x1)
        if x1==x2:
            exit()
    x1*=2
    print(x1)
    if x1==x2:
        exit()
    x2=int(input())
    if x1==x2:
        exit()
    x1*=2
    print(x1)
    if x1==x2:
        exit()
    x2=int(input())
    if x1==x2:
        exit()

while True:
    assert 10**9%x1==0
    assert 10**9%x2==0
    if x1==x2:
        exit()
    c12,c15=x_to_cnt(x1)
    c22,c25=x_to_cnt(x2)
    if abs(c12-c22)>=abs(c15-c25):
        if c12<c22:
            x1*=2
            c12+=1
        elif c12>c22:
            x1//=2
            c12-=1
        else:
            assert False
    else:
        if c15<c25:
            x1*=5
            c15+=1
        elif c15>c25:
            x1//=5
            c15-=1
        else:
            assert False
    print(x1)
    if x1==x2:
        exit()
    x2=int(input())
0