結果

問題 No.1152 10億ゲーム
ユーザー titiatitia
提出日時 2020-08-07 23:11:09
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 84 ms / 2,000 ms
コード長 2,949 bytes
コンパイル時間 510 ms
コンパイル使用メモリ 11,156 KB
実行使用メモリ 24,648 KB
平均クエリ数 23.10
最終ジャッジ日時 2023-09-24 04:58:56
合計ジャッジ時間 7,279 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 82 ms
24,608 KB
testcase_01 AC 79 ms
24,596 KB
testcase_02 AC 83 ms
24,108 KB
testcase_03 AC 84 ms
24,204 KB
testcase_04 AC 83 ms
23,940 KB
testcase_05 AC 84 ms
24,380 KB
testcase_06 AC 82 ms
24,100 KB
testcase_07 AC 82 ms
24,372 KB
testcase_08 AC 81 ms
24,244 KB
testcase_09 AC 80 ms
24,320 KB
testcase_10 AC 82 ms
24,648 KB
testcase_11 AC 81 ms
24,376 KB
testcase_12 AC 83 ms
24,360 KB
testcase_13 AC 83 ms
23,860 KB
testcase_14 AC 82 ms
24,636 KB
testcase_15 AC 82 ms
24,440 KB
testcase_16 AC 81 ms
24,112 KB
testcase_17 AC 83 ms
23,924 KB
testcase_18 AC 81 ms
23,588 KB
testcase_19 AC 83 ms
23,952 KB
testcase_20 AC 81 ms
24,324 KB
testcase_21 AC 80 ms
24,576 KB
testcase_22 AC 80 ms
24,172 KB
testcase_23 AC 79 ms
23,840 KB
testcase_24 AC 79 ms
24,540 KB
testcase_25 AC 81 ms
23,800 KB
testcase_26 AC 79 ms
23,644 KB
testcase_27 AC 82 ms
23,592 KB
testcase_28 AC 82 ms
23,664 KB
testcase_29 AC 83 ms
23,732 KB
testcase_30 AC 82 ms
24,284 KB
testcase_31 AC 81 ms
23,940 KB
testcase_32 AC 81 ms
23,948 KB
testcase_33 AC 81 ms
23,800 KB
testcase_34 AC 80 ms
23,972 KB
testcase_35 AC 82 ms
23,780 KB
testcase_36 AC 82 ms
24,252 KB
testcase_37 AC 80 ms
23,916 KB
testcase_38 AC 77 ms
24,352 KB
testcase_39 AC 80 ms
24,100 KB
testcase_40 AC 79 ms
24,084 KB
testcase_41 AC 78 ms
24,240 KB
testcase_42 AC 79 ms
24,384 KB
testcase_43 AC 81 ms
23,804 KB
testcase_44 AC 80 ms
24,348 KB
testcase_45 AC 79 ms
24,140 KB
testcase_46 AC 78 ms
23,988 KB
testcase_47 AC 80 ms
24,204 KB
testcase_48 AC 78 ms
23,924 KB
testcase_49 AC 78 ms
23,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

x1,x2=map(int,input().split())

def two_five(x):
    A=0
    while x%2==0:
        A+=1
        x//=2

    B=0
    while x%5==0:
        B+=1
        x//=5

    return [A,B]

x1=two_five(x1)
x2=two_five(x2)

def calc(x):
    return pow(2,x[0])*pow(5,x[1])

t=[7,9]
while x1!=x2:
    
    if (x1[0]+x1[1]-x2[0]-x2[1])%2==1:

        if x1!=x2:
            if abs(x1[0]-x2[0])+abs(x1[1]-x2[1])==1:
                x1=x2
                print(calc(x1))
                break
            
            if x1[1]+1<x2[1]:
                x1[1]+=1
                print(calc(x1),flush=True)

                if x1==x2:
                    break
                    

                k=int(input())
                x2=two_five(k)

            elif x1[1]>x2[1]+1:
                x1[1]-=1
                print(calc(x1),flush=True)

                if x1==x2:
                    break

                k=int(input())
                x2=two_five(k)

            else:
                if x1[0]+1<x2[0]:
                    x1[0]+=1
                    print(calc(x1),flush=True)
                    
                    if x1==x2:
                        break
                 
                    k=int(input())
                    x2=two_five(k)
                    
                else:
                    x1[0]-=1
                    print(calc(x1),flush=True)
                    
                    if x1==x2:
                        break

                    k=int(input())
                    x2=two_five(k)

    else:
        if x1!=t and x1!=x2:
            if abs(x1[0]-x2[0])+abs(x1[1]-x2[1])==1:
                x1=x2
                print(calc(x1))
                break
            
            if x1[1]<t[1]:
                x1[1]+=1
                print(calc(x1),flush=True)

                if x1==x2:
                    break
                    

                k=int(input())
                x2=two_five(k)

            elif x1[1]>t[1]:
                x1[1]-=1
                print(calc(x1),flush=True)

                if x1==x2:
                    break

                k=int(input())
                x2=two_five(k)

            else:
                if x1[0]<t[0]:
                    x1[0]+=1
                    print(calc(x1),flush=True)
                    
                    if x1==x2:
                        break
                 
                    k=int(input())
                    x2=two_five(k)
                    
                else:
                    x1[0]-=1
                    print(calc(x1),flush=True)
                    
                    if x1==x2:
                        break

                    k=int(input())
                    x2=two_five(k)
        elif x1==t:
            x1=[9,9]
            print(calc(x1),flush=True)

            if x1==x2:
                sys.exit()
                
            k=int(input())
            x2=two_five(k)
0