結果

問題 No.7 プライムナンバーゲーム
ユーザー nohakai3nohakai3
提出日時 2022-10-17 19:58:15
言語 Python3
(3.11.6 + numpy 1.26.0 + scipy 1.11.3)
結果
AC  
実行時間 1,889 ms / 5,000 ms
コード長 481 bytes
コンパイル時間 150 ms
コンパイル使用メモリ 10,980 KB
実行使用メモリ 8,416 KB
最終ジャッジ日時 2023-09-10 18:36:47
合計ジャッジ時間 13,722 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,780 KB
testcase_01 AC 16 ms
7,856 KB
testcase_02 AC 1,889 ms
8,416 KB
testcase_03 AC 138 ms
7,820 KB
testcase_04 AC 46 ms
7,852 KB
testcase_05 AC 45 ms
7,812 KB
testcase_06 AC 547 ms
7,864 KB
testcase_07 AC 374 ms
7,932 KB
testcase_08 AC 174 ms
7,864 KB
testcase_09 AC 841 ms
7,776 KB
testcase_10 AC 16 ms
7,860 KB
testcase_11 AC 383 ms
7,824 KB
testcase_12 AC 1,325 ms
8,292 KB
testcase_13 AC 1,433 ms
8,356 KB
testcase_14 AC 1,877 ms
8,228 KB
testcase_15 AC 1,763 ms
8,352 KB
testcase_16 AC 1,682 ms
8,304 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

prime = []
def setPrime(n):
    n += 1
    alive = [True] * n
    i = 2
    while i < n:
        if alive[i]:
            prime.append(i)
            j = 2 * i
            while j < n:
                alive[j] = False
                j += i
        i += 1
    
n=int(input())
setPrime(n)
dp=[False]*(n+1)
dp[0]=dp[1]=True
for i in range(2,n+1):
    for p in prime:
        if i-p<0:
            break
        dp[i] |= not dp[i-p]

if dp[n]:
    print("Win")
else:
    print("Lose")
0