結果
問題 | No.7 プライムナンバーゲーム |
ユーザー | togatoga |
提出日時 | 2015-08-15 07:50:42 |
言語 | PyPy2 (7.3.15) |
結果 |
AC
|
実行時間 | 744 ms / 5,000 ms |
コード長 | 678 bytes |
コンパイル時間 | 281 ms |
コンパイル使用メモリ | 77,112 KB |
実行使用メモリ | 85,028 KB |
最終ジャッジ日時 | 2024-04-09 03:49:58 |
合計ジャッジ時間 | 5,627 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 84 ms
77,868 KB |
testcase_01 | AC | 78 ms
77,888 KB |
testcase_02 | AC | 744 ms
85,028 KB |
testcase_03 | AC | 103 ms
79,124 KB |
testcase_04 | AC | 86 ms
78,908 KB |
testcase_05 | AC | 88 ms
78,612 KB |
testcase_06 | AC | 192 ms
81,576 KB |
testcase_07 | AC | 144 ms
80,428 KB |
testcase_08 | AC | 102 ms
79,260 KB |
testcase_09 | AC | 266 ms
82,060 KB |
testcase_10 | AC | 75 ms
77,860 KB |
testcase_11 | AC | 145 ms
80,804 KB |
testcase_12 | AC | 426 ms
83,332 KB |
testcase_13 | AC | 458 ms
83,476 KB |
testcase_14 | AC | 612 ms
84,524 KB |
testcase_15 | AC | 580 ms
84,520 KB |
testcase_16 | AC | 531 ms
84,524 KB |
ソースコード
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"