結果
問題 | No.7 プライムナンバーゲーム |
ユーザー | togatoga |
提出日時 | 2015-08-15 07:47:13 |
言語 | Python2 (2.7.18) |
結果 |
MLE
|
実行時間 | - |
コード長 | 622 bytes |
コンパイル時間 | 435 ms |
コンパイル使用メモリ | 6,516 KB |
実行使用メモリ | 775,760 KB |
最終ジャッジ日時 | 2023-09-25 11:58:32 |
合計ジャッジ時間 | 32,060 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 15 ms
6,700 KB |
testcase_01 | AC | 15 ms
6,768 KB |
testcase_02 | MLE | - |
testcase_03 | AC | 261 ms
41,004 KB |
testcase_04 | AC | 70 ms
12,628 KB |
testcase_05 | AC | 69 ms
12,556 KB |
testcase_06 | AC | 1,264 ms
203,408 KB |
testcase_07 | AC | 840 ms
132,360 KB |
testcase_08 | AC | 368 ms
56,108 KB |
testcase_09 | AC | 1,944 ms
320,324 KB |
testcase_10 | AC | 15 ms
6,632 KB |
testcase_11 | AC | 854 ms
133,928 KB |
testcase_12 | MLE | - |
testcase_13 | MLE | - |
testcase_14 | MLE | - |
testcase_15 | MLE | - |
testcase_16 | MLE | - |
ソースコード
import sys sys.setrecursionlimit(1 << 30) N = input() dp = [-1 for i in range(10010)] prime = [True for i in range(10010)] def sieve(): prime[0] = False prime[1] = False for i in range(2, 10010): if (prime[i]): for j in range(i * i, 10010, i): prime[j] = False def memo(pos): if (pos == 0 or pos == 1): return True win = False if (dp[pos] >= 0): return dp[pos] for i in range(2, pos): if (prime[i]): win |= not memo(pos - i) dp[pos] = win return win sieve() if (memo(N)): print "Win" else: print "Lose"