結果
問題 | No.7 プライムナンバーゲーム |
ユーザー | popketle |
提出日時 | 2020-01-30 17:03:31 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
AC
|
実行時間 | 763 ms / 5,000 ms |
コード長 | 676 bytes |
コンパイル時間 | 111 ms |
コンパイル使用メモリ | 12,800 KB |
実行使用メモリ | 11,264 KB |
最終ジャッジ日時 | 2024-04-09 04:49:03 |
合計ジャッジ時間 | 6,233 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 32 ms
10,880 KB |
testcase_01 | AC | 30 ms
11,008 KB |
testcase_02 | AC | 745 ms
11,264 KB |
testcase_03 | AC | 78 ms
11,008 KB |
testcase_04 | AC | 41 ms
10,880 KB |
testcase_05 | AC | 40 ms
10,880 KB |
testcase_06 | AC | 243 ms
11,136 KB |
testcase_07 | AC | 181 ms
10,880 KB |
testcase_08 | AC | 94 ms
11,008 KB |
testcase_09 | AC | 360 ms
11,136 KB |
testcase_10 | AC | 30 ms
10,752 KB |
testcase_11 | AC | 173 ms
11,008 KB |
testcase_12 | AC | 585 ms
11,264 KB |
testcase_13 | AC | 610 ms
11,264 KB |
testcase_14 | AC | 763 ms
11,264 KB |
testcase_15 | AC | 710 ms
11,264 KB |
testcase_16 | AC | 655 ms
11,264 KB |
ソースコード
n=int(input()) def eratosthenes(limit): import math A=[i for i in range(2,limit+1)] P=[] while True: prime=min(A) if prime>math.sqrt(limit): break P.append(prime) i=0 while i<len(A): if A[i]%prime==0: A.pop(i) continue i+=1 for a in A: P.append(a) return P P=eratosthenes(n) dp=[False]*(n+1) dp[0]=dp[1]=1 for i in range(2,n+1): for p in P: if i-p>=0 and not dp[i-p]: dp[i]=True break else: dp[i]=False print('Win') if dp[n] else print('Lose')