結果

問題 No.683 Two Operations No.3
ユーザー ntuda
提出日時 2025-01-12 21:14:40
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 48 ms / 2,000 ms
コード長 549 bytes
コンパイル時間 478 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 52,224 KB
最終ジャッジ日時 2025-01-12 21:14:44
合計ジャッジ時間 2,401 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 16
権限があれば一括ダウンロードができます

ソースコード

diff #

A, B = map(int, input().split())
if A > B:
    A, B = B, A

Q = {(A, B)}
Q2 = {(A, B)}
while Q:
    a, b = Q.pop()
    if a == 0 or b == 0:
        print("Yes")
        exit()
    if a % 2 == 0:
        c = a // 2
        d = b - 1
        if c > d:
            c, d = d, c
        if (c, d) not in Q2:
            Q.add((c, d))
            Q2.add((c, d))
    if b % 2 == 0:
        c = b // 2
        d = a - 1
        if c > d:
            c, d = d, c
        if (c, d) not in Q2:
            Q.add((c, d))
            Q2.add((c, d))

print("No")
0