結果

問題 No.7 プライムナンバーゲーム
ユーザー netyo715netyo715
提出日時 2021-06-21 11:20:36
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 489 bytes
コンパイル時間 532 ms
コンパイル使用メモリ 10,924 KB
実行使用メモリ 9,732 KB
最終ジャッジ日時 2023-09-05 01:49:46
合計ジャッジ時間 1,900 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 RE -
testcase_03 RE -
testcase_04 WA -
testcase_05 WA -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 WA -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())

hurui = set(range(2, N+1))
for i in range(2, N+1):
    for j in range(i*2, N+1, i):
        hurui.discard(j)

dp = [-1]*(N+10)
dp[0] = 0
dp[1] = 0
def grundy(x):
    if dp[x] != -1:
        return dp[x]
    s = set()
    for i in range(2, x+1):
        if i in hurui:
            s.add(grundy(x-i))
    for i in range(x+1):
        if i not in s:
            dp[x] = i
            print(x, i)
            return i

if grundy(N)&1:
    print("Lose")
else:
    print("Win")
0