結果

問題 No.683 Two Operations No.3
ユーザー nebukuro09nebukuro09
提出日時 2018-05-11 22:34:55
言語 PyPy2
(7.3.15)
結果
AC  
実行時間 78 ms / 2,000 ms
コード長 566 bytes
コンパイル時間 1,556 ms
コンパイル使用メモリ 76,444 KB
実行使用メモリ 75,648 KB
最終ジャッジ日時 2024-06-28 09:53:52
合計ジャッジ時間 3,480 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 16
権限があれば一括ダウンロードができます

ソースコード

diff #

a, b = map(int, raw_input().split())

stack = [(a, b)]
d = set()
while len(stack) > 0:
    x, y = stack[-1]
    stack.pop()
    if x == 0 or y == 0:
        print "Yes"
        exit()
    if (x, y) in d:
        continue
    if x % 2 == 1 and y % 2 == 1:
        continue
    d.add((x, y))
    if y > 0 and x % 2 == 0:
        xx = x / 2
        yy = y - 1
        if (xx, yy) not in d:
            stack.append((xx, yy))
    if x > 0 and y % 2 == 0:
        xx = x - 1
        yy = y / 2
        if (xx, yy) not in d:
            stack.append((xx, yy))

print "No"
0