結果

問題 No.683 Two Operations No.3
ユーザー Theta
提出日時 2022-11-18 17:50:42
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 29 ms / 2,000 ms
コード長 572 bytes
コンパイル時間 105 ms
コンパイル使用メモリ 12,416 KB
実行使用メモリ 10,624 KB
最終ジャッジ日時 2024-09-19 23:28:24
合計ジャッジ時間 1,178 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 16
権限があれば一括ダウンロードができます

ソースコード

diff #

from functools import lru_cache
import sys
sys.setrecursionlimit(100000)


@lru_cache
def is_operated(a: int, b: int) -> bool:
    if a == 0 or b == 0:
        return True
    if a % 2 == 1 and b % 2 == 1:
        return False

    if a % 2 == 1:
        return is_operated(a-1, b//2)

    if b % 2 == 1:
        return is_operated(a//2, b-1)

    return is_operated(a-1, b//2) or is_operated(a//2, b-1)


def main():
    A, B = map(int, input().split())
    if is_operated(A, B):
        print("Yes")
    else:
        print("No")


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