結果

問題 No.1579 New Type of Nim
ユーザー c-yanc-yan
提出日時 2021-07-02 22:20:46
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 967 bytes
コンパイル時間 111 ms
コンパイル使用メモリ 10,888 KB
実行使用メモリ 8,416 KB
最終ジャッジ日時 2023-09-11 22:26:05
合計ジャッジ時間 2,022 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 16 ms
8,316 KB
testcase_14 AC 16 ms
8,332 KB
testcase_15 WA -
testcase_16 AC 16 ms
8,256 KB
testcase_17 WA -
testcase_18 AC 16 ms
8,220 KB
testcase_19 WA -
testcase_20 AC 15 ms
8,220 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 16 ms
8,188 KB
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 16 ms
8,320 KB
testcase_31 WA -
testcase_32 WA -
testcase_33 AC 16 ms
8,288 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

A, B = map(int, input().split())

def f(a, b, turn):
    if a == 0 or b == 0:
        return turn
    if a >= 5:
        if f(4, b, turn ^ 1) == turn:
            return turn
    if a >= 4:
        if f(3, b, turn ^ 1) == turn:
            return turn
    if a >= 3:
        if f(2, b, turn ^ 1) == turn:
            return turn
    if a >= 2:
        if f(1, b, turn ^ 1) == turn:
            return turn
    if a >= 1:
        if f(0, b, turn ^ 1) == turn:
            return turn
    if b >= 5:
        if f(a, 4, turn ^ 1) == turn:
            return turn
    if b >= 4:
        if f(a, 3, turn ^ 1) == turn:
            return turn
    if b >= 3:
        if f(a, 2, turn ^ 1) == turn:
            return turn
    if b >= 2:
        if f(a, 1, turn ^ 1) == turn:
            return turn
    if b >= 1:
        if f(a, 0, turn ^ 1) == turn:
            return turn
    return turn ^ 1

turn = f(A, B, 0)
if turn == 0:
    print('P')
elif turn == 1:
    print('Q')
0