結果
問題 | No.7 プライムナンバーゲーム |
ユーザー | zombietan |
提出日時 | 2016-05-08 02:07:54 |
言語 | Python3 (3.11.6 + numpy 1.26.0 + scipy 1.11.3) |
結果 |
AC
|
実行時間 | 1,781 ms / 5,000 ms |
コード長 | 581 bytes |
コンパイル時間 | 316 ms |
コンパイル使用メモリ | 10,928 KB |
実行使用メモリ | 8,416 KB |
最終ジャッジ日時 | 2023-07-24 20:36:27 |
合計ジャッジ時間 | 12,227 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge12 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 16 ms
7,876 KB |
testcase_01 | AC | 16 ms
7,772 KB |
testcase_02 | AC | 1,621 ms
8,416 KB |
testcase_03 | AC | 127 ms
7,872 KB |
testcase_04 | AC | 46 ms
7,848 KB |
testcase_05 | AC | 44 ms
7,828 KB |
testcase_06 | AC | 489 ms
8,284 KB |
testcase_07 | AC | 367 ms
7,860 KB |
testcase_08 | AC | 172 ms
7,856 KB |
testcase_09 | AC | 712 ms
8,308 KB |
testcase_10 | AC | 15 ms
7,796 KB |
testcase_11 | AC | 353 ms
7,844 KB |
testcase_12 | AC | 1,144 ms
8,408 KB |
testcase_13 | AC | 1,191 ms
8,248 KB |
testcase_14 | AC | 1,781 ms
8,384 KB |
testcase_15 | AC | 1,627 ms
8,288 KB |
testcase_16 | AC | 1,374 ms
8,240 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 = ['']*(N+1) memo[0] = 'Win' memo[1] = 'Win' for i in range(2, N+1): c = [] for s in r: if s <= i: h = memo[i-s] c.append(h) else: break if 'Lose' in c: memo[i] = 'Win' else: memo[i] = 'Lose' print(memo[N])