結果

問題 No.683 Two Operations No.3
ユーザー LyricalMaestro
提出日時 2025-10-04 02:07:56
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 70 ms / 2,000 ms
コード長 1,056 bytes
コンパイル時間 492 ms
コンパイル使用メモリ 82,496 KB
実行使用メモリ 62,980 KB
最終ジャッジ日時 2025-10-04 02:07:59
合計ジャッジ時間 2,510 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 16
権限があれば一括ダウンロードができます

ソースコード

diff #

## https://yukicoder.me/problems/no/683

from collections import deque

def main():
    A, B = map(int, input().split())
    if A == 0 or B == 0:
        print("Yes")
        return

    a_set = {(A, B)}
    queue = deque()
    queue.append((A, B))
    while len(queue) > 0:
        x, y = queue.popleft()

        if x % 2 == 0 and y > 0:
            new_x = x // 2 
            new_y = y - 1
            if new_x == 0 or new_y == 0:
                print("Yes")
                return

            if (new_x, new_y) not in a_set:
                a_set.add((new_x, new_y))
                queue.append((new_x, new_y))

        if x > 0 and y % 2 == 0:
            new_x = x - 1 
            new_y = y // 2
            if new_x == 0 or new_y == 0:
                print("Yes")
                return

            if (new_x, new_y) not in a_set:
                a_set.add((new_x, new_y))
                queue.append((new_x, new_y))

    if (0, 0) in a_set:
        print("Yes")
    else:
        print("No")



    



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