結果

問題 No.7 プライムナンバーゲーム
ユーザー cleanttedcleantted
提出日時 2016-10-09 02:03:50
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,176 ms / 5,000 ms
コード長 426 bytes
コンパイル時間 92 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 10,880 KB
最終ジャッジ日時 2024-04-09 04:03:21
合計ジャッジ時間 8,881 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 31 ms
10,752 KB
testcase_01 AC 30 ms
10,752 KB
testcase_02 AC 1,176 ms
10,752 KB
testcase_03 AC 96 ms
10,752 KB
testcase_04 AC 45 ms
10,752 KB
testcase_05 AC 45 ms
10,752 KB
testcase_06 AC 344 ms
10,752 KB
testcase_07 AC 239 ms
10,752 KB
testcase_08 AC 119 ms
10,752 KB
testcase_09 AC 521 ms
10,752 KB
testcase_10 AC 29 ms
10,752 KB
testcase_11 AC 245 ms
10,752 KB
testcase_12 AC 832 ms
10,880 KB
testcase_13 AC 881 ms
10,752 KB
testcase_14 AC 1,165 ms
10,752 KB
testcase_15 AC 1,108 ms
10,752 KB
testcase_16 AC 1,026 ms
10,880 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
memo = [False] * (N+1)
prime = []

memo[0] = True
memo[1] = True

#素数列を作る(=prime)
for n in range(2,N+1):
    flag = True
    for m in range(2, n):
        if n%m == 0:
            flag = False
            break
    if flag: prime.append(n)

for i in range(N+1):
    if not memo[i]:
        for p in prime:
            if i + p <= N: memo[i + p] = True

if memo[N]: print("Win")
else: print("Lose")
0