結果
問題 | No.7 プライムナンバーゲーム |
ユーザー | togatoga |
提出日時 | 2015-08-15 07:51:08 |
言語 | Python2 (2.7.18) |
結果 |
MLE
|
実行時間 | - |
コード長 | 678 bytes |
コンパイル時間 | 651 ms |
コンパイル使用メモリ | 6,652 KB |
実行使用メモリ | 775,608 KB |
最終ジャッジ日時 | 2023-09-25 11:59:16 |
合計ジャッジ時間 | 20,099 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 16 ms
6,676 KB |
testcase_01 | AC | 15 ms
6,680 KB |
testcase_02 | MLE | - |
testcase_03 | AC | 155 ms
40,776 KB |
testcase_04 | AC | 43 ms
12,860 KB |
testcase_05 | AC | 42 ms
12,460 KB |
testcase_06 | AC | 723 ms
203,416 KB |
testcase_07 | AC | 480 ms
131,972 KB |
testcase_08 | AC | 211 ms
56,276 KB |
testcase_09 | AC | 1,121 ms
320,144 KB |
testcase_10 | AC | 15 ms
6,636 KB |
testcase_11 | AC | 492 ms
133,888 KB |
testcase_12 | MLE | - |
testcase_13 | MLE | - |
testcase_14 | MLE | - |
testcase_15 | MLE | - |
testcase_16 | MLE | - |
ソースコード
import sys import time 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) if (win): break dp[pos] = win return win sieve() if (memo(N)): print "Win" else: print "Lose"