結果

問題 No.683 Two Operations No.3
ユーザー nadarenadare
提出日時 2018-05-11 23:31:04
言語 Python3
(3.11.6 + numpy 1.26.0 + scipy 1.11.3)
結果
AC  
実行時間 18 ms / 2,000 ms
コード長 630 bytes
コンパイル時間 271 ms
コンパイル使用メモリ 10,872 KB
実行使用メモリ 8,108 KB
最終ジャッジ日時 2023-09-10 18:46:02
合計ジャッジ時間 1,287 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 18 ms
7,816 KB
testcase_01 AC 16 ms
7,796 KB
testcase_02 AC 16 ms
7,800 KB
testcase_03 AC 16 ms
8,108 KB
testcase_04 AC 17 ms
7,792 KB
testcase_05 AC 16 ms
7,796 KB
testcase_06 AC 16 ms
7,848 KB
testcase_07 AC 17 ms
7,848 KB
testcase_08 AC 17 ms
7,856 KB
testcase_09 AC 16 ms
7,860 KB
testcase_10 AC 17 ms
7,836 KB
testcase_11 AC 16 ms
7,832 KB
testcase_12 AC 16 ms
7,852 KB
testcase_13 AC 16 ms
7,832 KB
testcase_14 AC 16 ms
7,976 KB
testcase_15 AC 16 ms
7,816 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# -*- coding: utf-8 -*-
def inpl(): return map(int, input().split())

A, B = inpl()
if A==0 and B==0:
    print("Yes")
    exit()
Q = [[A, B]]

c = 0
while Q:
    c += 1
    a, b = Q.pop()
    if a%2==0:
        na, nb = a//2, b-1
        if na == 0 or nb == 0:
            print("Yes")
            break
        
        if nb >= 0: # and (not searched[(na, nb)])
            Q.append([na, nb])
    
    if b%2==0:
        na, nb = a-1, b//2
        if na == 0 or nb == 0:
            print("Yes")
            break
        
        if na >= 0: # and (not searched[(na, nb)])
            Q.append([na, nb])

else:
    print("No")
0