結果
問題 | No.7 プライムナンバーゲーム |
ユーザー | nsd_fb |
提出日時 | 2015-02-19 04:21:11 |
言語 | Python2 (2.7.18) |
結果 |
RE
|
実行時間 | - |
コード長 | 744 bytes |
コンパイル時間 | 70 ms |
コンパイル使用メモリ | 6,672 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2023-09-06 02:21:00 |
合計ジャッジ時間 | 1,638 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 12 ms
6,048 KB |
testcase_01 | AC | 12 ms
6,052 KB |
testcase_02 | RE | - |
testcase_03 | RE | - |
testcase_04 | RE | - |
testcase_05 | RE | - |
testcase_06 | RE | - |
testcase_07 | RE | - |
testcase_08 | RE | - |
testcase_09 | RE | - |
testcase_10 | AC | 11 ms
6,024 KB |
testcase_11 | RE | - |
testcase_12 | RE | - |
testcase_13 | RE | - |
testcase_14 | RE | - |
testcase_15 | RE | - |
testcase_16 | RE | - |
ソースコード
import functools def memoize(obj): cache = obj.cache = {} @functools.wraps(obj) def memoizer(*args, **kwargs): if args not in cache: cache[args] = obj(*args, **kwargs) return cache[args] return memoizer def sieve(n): res = [] is_prime = [True] * (n + 1) for i in xrange(2, n + 1): if is_prime[i]: res.append(i) for j in xrange(i * i, n + 1, i): is_prime[j] = False return res @memoize def win(n): if n <= 1: return True for p in primes: if p > n: break if not win(n - p): return True return False n = input() primes = sieve(n) print 'Win' if win(n) else 'Lose'