結果

問題 No.683 Two Operations No.3
ユーザー kamomekamome
提出日時 2019-07-04 22:27:59
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 32 ms / 2,000 ms
コード長 885 bytes
コンパイル時間 131 ms
コンパイル使用メモリ 11,992 KB
実行使用メモリ 10,216 KB
最終ジャッジ日時 2023-10-19 10:37:47
合計ジャッジ時間 1,323 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 32 ms
10,192 KB
testcase_01 AC 32 ms
10,192 KB
testcase_02 AC 31 ms
10,192 KB
testcase_03 AC 30 ms
10,192 KB
testcase_04 AC 30 ms
10,216 KB
testcase_05 AC 30 ms
10,216 KB
testcase_06 AC 30 ms
10,192 KB
testcase_07 AC 30 ms
10,192 KB
testcase_08 AC 30 ms
10,192 KB
testcase_09 AC 29 ms
10,216 KB
testcase_10 AC 29 ms
10,192 KB
testcase_11 AC 29 ms
10,192 KB
testcase_12 AC 31 ms
10,196 KB
testcase_13 AC 29 ms
10,196 KB
testcase_14 AC 30 ms
10,192 KB
testcase_15 AC 31 ms
10,196 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/python3
import sys
sys.setrecursionlimit(10000)

def op(x,y):
    if x==0 or y==0:
        print("Yes")
        exit()
    x_mul2=(x%2==0)
    y_mul2=(y%2==0)
    if (not x_mul2) and (not y_mul2):
        return
    elif x_mul2 and y_mul2:
        if (x//2)%2==1:
            op(x-1,y//2)
        elif(y//2)%2==1:
            op(x//2,y-1)
        else:
            op(x-1,y//2)
            op(x//2,y-1)
    elif x_mul2:
        op(x//2,y-1)
    else:
        op(x-1,y//2)
            
def op1(x,y):
    if x==0 and y==0:
        print("Yes")
        exit()
    if x%2==0 and y>0:
        x=x//2
        y=y-1
        op2(x,y)
        op1(x,y)

def op2(x,y):
    if x==0 and y==0:
        print("Yes")
        exit()
    if x>0 and y%2==0:
        x=x-1
        y=y//2
        op1(x//2,y-1)
        op2(x-1,y//2)


X,Y=map(int,input().split())
op(X,Y)
#op2(X,Y)
print("No")

0