結果

問題 No.1152 10億ゲーム
ユーザー kimiyukikimiyuki
提出日時 2020-08-16 01:32:43
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
RE  
実行時間 -
コード長 1,215 bytes
コンパイル時間 100 ms
コンパイル使用メモリ 11,068 KB
実行使用メモリ 26,212 KB
平均クエリ数 24.76
最終ジャッジ日時 2023-09-24 05:37:55
合計ジャッジ時間 8,588 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 107 ms
25,572 KB
testcase_01 AC 100 ms
26,068 KB
testcase_02 RE -
testcase_03 RE -
testcase_04 AC 101 ms
25,952 KB
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 AC 100 ms
25,816 KB
testcase_09 AC 100 ms
25,824 KB
testcase_10 AC 101 ms
25,628 KB
testcase_11 AC 102 ms
26,060 KB
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 AC 101 ms
25,592 KB
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 AC 100 ms
25,836 KB
testcase_21 AC 101 ms
25,720 KB
testcase_22 AC 100 ms
25,752 KB
testcase_23 AC 101 ms
26,112 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 RE -
testcase_35 RE -
testcase_36 RE -
testcase_37 RE -
testcase_38 AC 99 ms
25,848 KB
testcase_39 AC 99 ms
26,200 KB
testcase_40 AC 101 ms
25,484 KB
testcase_41 AC 100 ms
25,528 KB
testcase_42 RE -
testcase_43 RE -
testcase_44 RE -
testcase_45 RE -
testcase_46 AC 97 ms
25,528 KB
testcase_47 AC 97 ms
25,908 KB
testcase_48 AC 97 ms
25,340 KB
testcase_49 AC 97 ms
25,508 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/env python3
import sys
from typing import *

def pack(x: int, y: int) -> int:
    return 2 ** x * 5 ** y

def unpack(n: int) -> Tuple[int, int]:
    x, y = 0, 0
    while n % 2 == 0:
        x += 1
        n //= 2
    while n % 5 == 0:
        y += 1
        n //= 5
    assert n == 1
    return x, y

H = 10
W = 10
def solve(a: int, b: int) -> int:
    ax, ay = unpack(a)
    bx, by = unpack(b)
    swappped = False
    if abs(bx - ax) > abs(by - ay):
        swappped = True
        ax, ay = ay, ax
        bx, by = by, bx
    if abs(bx - ax) + abs(by - ay) == 1:
        ax = bx
        ay = by
    elif bx <= ax - 2:
        ax -= 1
    elif bx >= ax + 2:
        ax += 1
    elif by < ay:
        ay -= 1
    elif by > ay:
        ay += 1
    elif bx < ax:
        ax -= 1
    elif bx > ax:
        ax += 1
    else:
        assert False
    if swappped:
        ax, ay = ay, ax
        bx, by = by, bx
    return pack(ax, ay)

def main():
    a, b = map(int, input().split())
    while True:
        a = solve(a, b)
        print(a)
        sys.stdout.flush()
        if a == b:
            break
        b = int(input())
        if a == b:
            break

if __name__ == '__main__':
    main()
0