結果

問題 No.1579 New Type of Nim
ユーザー shotoyooshotoyoo
提出日時 2021-07-02 22:32:59
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 88 ms / 2,000 ms
コード長 976 bytes
コンパイル時間 616 ms
コンパイル使用メモリ 86,436 KB
実行使用メモリ 76,128 KB
最終ジャッジ日時 2023-09-30 11:16:50
合計ジャッジ時間 4,757 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 88 ms
75,928 KB
testcase_01 AC 81 ms
75,876 KB
testcase_02 AC 83 ms
75,836 KB
testcase_03 AC 82 ms
75,924 KB
testcase_04 AC 82 ms
75,768 KB
testcase_05 AC 82 ms
75,944 KB
testcase_06 AC 84 ms
75,936 KB
testcase_07 AC 86 ms
75,724 KB
testcase_08 AC 88 ms
75,700 KB
testcase_09 AC 86 ms
75,652 KB
testcase_10 AC 87 ms
75,764 KB
testcase_11 AC 86 ms
75,948 KB
testcase_12 AC 87 ms
75,764 KB
testcase_13 AC 88 ms
75,708 KB
testcase_14 AC 87 ms
75,860 KB
testcase_15 AC 85 ms
75,712 KB
testcase_16 AC 85 ms
75,760 KB
testcase_17 AC 86 ms
76,128 KB
testcase_18 AC 82 ms
75,544 KB
testcase_19 AC 82 ms
76,032 KB
testcase_20 AC 81 ms
76,044 KB
testcase_21 AC 83 ms
75,832 KB
testcase_22 AC 82 ms
76,056 KB
testcase_23 AC 82 ms
75,476 KB
testcase_24 AC 82 ms
75,868 KB
testcase_25 AC 83 ms
76,112 KB
testcase_26 AC 84 ms
76,012 KB
testcase_27 AC 83 ms
76,108 KB
testcase_28 AC 84 ms
76,108 KB
testcase_29 AC 83 ms
75,840 KB
testcase_30 AC 82 ms
75,772 KB
testcase_31 AC 81 ms
75,924 KB
testcase_32 AC 82 ms
75,792 KB
testcase_33 AC 82 ms
75,948 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = lambda : sys.stdin.readline().rstrip()

sys.setrecursionlimit(2*10**5+10)
write = lambda x: sys.stdout.write(x+"\n")
debug = lambda x: sys.stderr.write(x+"\n")
writef = lambda x: print("{:.12f}".format(x))


a,b = list(map(int, input().split()))
n = 20
dp = [[0]*n for _ in range(n)]
for i in range(n):
    dp[i][0] = dp[0][i] = 1
for i in range(n):
    for j in range(n):
        if i==j==0:
            continue
        if i==0 or j==0:
            continue
        ok = 0
        for k in range(1,i+1):
            if i-k==j:
                continue
            if dp[i-k][j]==0:
                ok = 1
        for k in range(1,j+1):
            if j-k==i:
                continue
            if dp[i][j-k]==0:
                ok = 1
        dp[i][j] = ok
if a==b:
    if a%2==0:
        ans = "P"
    else:
        ans = "Q"
elif abs(a-b)==1:
    v = min(a,b)
    if v%2==0:
        ans = "P"
    else:
        ans = "Q"
else:
    ans = "P"
print(ans)
0