結果

問題 No.683 Two Operations No.3
ユーザー maspymaspy
提出日時 2020-02-05 22:11:22
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 500 bytes
コンパイル時間 453 ms
コンパイル使用メモリ 11,840 KB
実行使用メモリ 10,520 KB
最終ジャッジ日時 2023-10-24 11:22:20
合計ジャッジ時間 2,786 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 RE -
testcase_07 WA -
testcase_08 RE -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 RE -
testcase_13 RE -
testcase_14 WA -
testcase_15 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

from functools import lru_cache

A, B = map(int, read().split())

@lru_cache(None)
def solve(A, B):
    if A == B == 0:
        return True
    if A < 0 or B < 0:
        return False
    if A % 2 == 0 and solve(A // 2, B - 1):
        return True
    if B % 2 == 0 and solve(A - 1, B // 2):
        return True
    return False

answer = 'YES' if solve(A, B) else 'NO'
print(answer)
0