結果
問題 | No.7 プライムナンバーゲーム |
ユーザー | masumasumath1 |
提出日時 | 2019-11-30 10:44:00 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 895 bytes |
コンパイル時間 | 81 ms |
コンパイル使用メモリ | 10,816 KB |
実行使用メモリ | 8,472 KB |
最終ジャッジ日時 | 2023-08-13 08:09:04 |
合計ジャッジ時間 | 6,122 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 15 ms
7,816 KB |
testcase_01 | WA | - |
testcase_02 | AC | 756 ms
8,448 KB |
testcase_03 | AC | 61 ms
7,920 KB |
testcase_04 | AC | 29 ms
7,868 KB |
testcase_05 | WA | - |
testcase_06 | AC | 227 ms
7,804 KB |
testcase_07 | AC | 154 ms
7,908 KB |
testcase_08 | AC | 77 ms
7,788 KB |
testcase_09 | WA | - |
testcase_10 | AC | 16 ms
7,788 KB |
testcase_11 | AC | 169 ms
7,812 KB |
testcase_12 | AC | 544 ms
8,352 KB |
testcase_13 | AC | 561 ms
8,396 KB |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | AC | 653 ms
8,384 KB |
ソースコード
def isPrime(n): if n < 2: return False for i in range(2,n): #iはsqrt(n)まで調べれば十分 if i*i > n: break #一度でもiで割り切れたら素数ではない if n%i == 0: return False #forを抜けたら素数 return True #n以下の素数列挙 def mkP_tridiv(n): for i in range(n+1): if isPrime(i): P.append(i) N = int(input()) #N以下の素数をPに格納 P = [] mkP_tridiv(N) #数字iで回ってきたときに自分が勝てるかどうか #勝てるTrue,負けるFalse A = [ False for i in range(N+1)] #0,1で回ってきたら勝ちとする A[0],A[1] = True,True for i in range(1,N+1): for p in P: if i-p >= 0 and not A[i-p]: A[i] = True break else: A[i] = False if A[N]: print("Win") else: print("Lose")