結果

問題 No.683 Two Operations No.3
ユーザー kerotonokerotono
提出日時 2018-05-11 23:55:51
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 16 ms / 2,000 ms
コード長 681 bytes
コンパイル時間 175 ms
コンパイル使用メモリ 10,788 KB
実行使用メモリ 7,868 KB
最終ジャッジ日時 2023-09-10 18:46:18
合計ジャッジ時間 1,152 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,780 KB
testcase_01 AC 16 ms
7,720 KB
testcase_02 AC 16 ms
7,692 KB
testcase_03 AC 15 ms
7,764 KB
testcase_04 AC 14 ms
7,812 KB
testcase_05 AC 15 ms
7,808 KB
testcase_06 AC 15 ms
7,832 KB
testcase_07 AC 15 ms
7,764 KB
testcase_08 AC 15 ms
7,832 KB
testcase_09 AC 15 ms
7,868 KB
testcase_10 AC 15 ms
7,764 KB
testcase_11 AC 15 ms
7,732 KB
testcase_12 AC 15 ms
7,728 KB
testcase_13 AC 15 ms
7,708 KB
testcase_14 AC 15 ms
7,780 KB
testcase_15 AC 15 ms
7,836 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

import sys

sys.setrecursionlimit(10 ** 8)


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

    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')
# for x in range(100):
#     for y in range(100):
#         a = 4 * x + 1
#         b = 4 * y + 2
#         if DFS(a, b):
#             print(a, b)
#         else:
#             print()
0