結果

問題 No.683 Two Operations No.3
ユーザー kerotonokerotono
提出日時 2018-05-11 23:17:42
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 537 bytes
コンパイル時間 131 ms
コンパイル使用メモリ 10,984 KB
実行使用メモリ 71,216 KB
最終ジャッジ日時 2023-09-10 17:50:01
合計ジャッジ時間 3,982 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#!python
# -*- coding: utf-8 -*-

import sys

sys.setrecursionlimit(10 ** 8)


T = []

for i in range(60):
    T.append(2 ** i)


def DFS(A, B):
    if A == 0 and B == 0:
        return True
    if A % 2 == 1 and B % 2 == 1:
        return False

    if A in T or B in T:
        return True

    if A % 2 == 1:
        return DFS(A - 1, B // 2)
    elif B % 2 == 1:
        return DFS(A // 2, B - 1)
    else:
        return DFS(A - 1, B // 2) or DFS(A // 2, B - 1)

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