結果
問題 | No.7 プライムナンバーゲーム |
ユーザー | zombietan |
提出日時 | 2016-05-08 03:06:21 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
AC
|
実行時間 | 553 ms / 5,000 ms |
コード長 | 580 bytes |
コンパイル時間 | 401 ms |
コンパイル使用メモリ | 12,544 KB |
実行使用メモリ | 11,008 KB |
最終ジャッジ日時 | 2024-04-09 04:00:09 |
合計ジャッジ時間 | 5,031 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 31 ms
10,752 KB |
testcase_01 | AC | 30 ms
10,752 KB |
testcase_02 | AC | 553 ms
10,880 KB |
testcase_03 | AC | 63 ms
10,752 KB |
testcase_04 | AC | 41 ms
10,752 KB |
testcase_05 | AC | 40 ms
10,752 KB |
testcase_06 | AC | 198 ms
10,752 KB |
testcase_07 | AC | 128 ms
10,880 KB |
testcase_08 | AC | 77 ms
10,880 KB |
testcase_09 | AC | 247 ms
10,752 KB |
testcase_10 | AC | 30 ms
10,752 KB |
testcase_11 | AC | 132 ms
10,752 KB |
testcase_12 | AC | 389 ms
10,880 KB |
testcase_13 | AC | 407 ms
10,880 KB |
testcase_14 | AC | 509 ms
11,008 KB |
testcase_15 | AC | 488 ms
10,880 KB |
testcase_16 | AC | 450 ms
10,880 KB |
ソースコード
N = int(input()) def primes(): n = 2 p = [] while True: if not any( n % f == 0 for f in p ): yield(n) p.append( n ) n += 1 p = primes() r = [] while True: d = next(p) if d <= N: r.append(d) else: break memo = ['Lose']*(N+1) memo[0] = 'Win' memo[1] = 'Win' for i in range(2, N+1): c = set() for s in r: if s > i: break elif memo[i-s] == 'Lose': #素数を引いて一つでも'Lose'があれば'Win' memo[i] = 'Win' break print(memo[N])