結果

問題 No.7 プライムナンバーゲーム
ユーザー ああいいああいい
提出日時 2021-12-04 17:46:28
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 620 ms / 5,000 ms
コード長 536 bytes
コンパイル時間 161 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 11,008 KB
最終ジャッジ日時 2024-04-09 05:06:08
合計ジャッジ時間 5,367 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 31 ms
10,880 KB
testcase_01 AC 30 ms
10,752 KB
testcase_02 AC 615 ms
10,880 KB
testcase_03 AC 68 ms
10,752 KB
testcase_04 AC 38 ms
10,752 KB
testcase_05 AC 38 ms
10,752 KB
testcase_06 AC 198 ms
10,752 KB
testcase_07 AC 148 ms
10,752 KB
testcase_08 AC 80 ms
10,752 KB
testcase_09 AC 284 ms
11,008 KB
testcase_10 AC 30 ms
10,752 KB
testcase_11 AC 143 ms
10,752 KB
testcase_12 AC 440 ms
10,880 KB
testcase_13 AC 462 ms
10,880 KB
testcase_14 AC 620 ms
11,008 KB
testcase_15 AC 577 ms
10,880 KB
testcase_16 AC 535 ms
10,880 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())

dat = [0] * (N+1)
prime = []
for i in range(2,N+1):
    if dat[i] == 0:
        prime.append(i)
        j = 2
        while i * j <= N:
            dat[i*j] = 1
            j += 1
winlose = [0] * (N+1)
winlose[2] = False
winlose[3] = False
for i in range(4,N+1):
    for j in prime:
        if i - j < 2:
            winlose[i] = False
            break
        else:
            if winlose[i-j] == False:
                winlose[i] = True
                break
if winlose[N]:
    print('Win')
else:
    print('Lose')
0