結果

問題 No.683 Two Operations No.3
ユーザー H3PO4H3PO4
提出日時 2020-11-24 11:46:17
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 22 ms / 2,000 ms
コード長 464 bytes
コンパイル時間 657 ms
コンパイル使用メモリ 10,884 KB
実行使用メモリ 8,932 KB
最終ジャッジ日時 2023-10-01 00:51:08
合計ジャッジ時間 1,375 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 20 ms
8,656 KB
testcase_01 AC 21 ms
8,560 KB
testcase_02 AC 20 ms
8,668 KB
testcase_03 AC 20 ms
8,576 KB
testcase_04 AC 22 ms
8,932 KB
testcase_05 AC 21 ms
8,908 KB
testcase_06 AC 20 ms
8,660 KB
testcase_07 AC 20 ms
8,612 KB
testcase_08 AC 20 ms
8,752 KB
testcase_09 AC 21 ms
8,740 KB
testcase_10 AC 20 ms
8,612 KB
testcase_11 AC 20 ms
8,564 KB
testcase_12 AC 20 ms
8,740 KB
testcase_13 AC 21 ms
8,584 KB
testcase_14 AC 21 ms
8,664 KB
testcase_15 AC 21 ms
8,772 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
from functools import lru_cache

sys.setrecursionlimit(10 ** 9)


@lru_cache(None)
def rec(a, b):
    # 片方0なら必ずいけるので打ち切るとよい
    if a * b == 0:
        return True
    elif a % 2 and b % 2:
        return False

    res = False
    if not a % 2:
        res |= rec(a // 2, b - 1)
    if not b % 2:
        res |= rec(a - 1, b // 2)
    return res


A, B = map(int, input().split())
print('Yes' if rec(A, B) else 'No')
0