結果

問題 No.7 プライムナンバーゲーム
ユーザー DrDrpilotDrDrpilot
提出日時 2022-06-07 18:16:22
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 235 ms / 5,000 ms
コード長 524 bytes
コンパイル時間 274 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 11,008 KB
最終ジャッジ日時 2024-04-09 05:07:58
合計ジャッジ時間 2,923 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 31 ms
10,880 KB
testcase_01 AC 32 ms
10,880 KB
testcase_02 AC 230 ms
11,008 KB
testcase_03 AC 43 ms
10,880 KB
testcase_04 AC 34 ms
10,880 KB
testcase_05 AC 33 ms
11,008 KB
testcase_06 AC 88 ms
10,880 KB
testcase_07 AC 70 ms
10,880 KB
testcase_08 AC 48 ms
10,880 KB
testcase_09 AC 119 ms
11,008 KB
testcase_10 AC 31 ms
10,880 KB
testcase_11 AC 71 ms
10,880 KB
testcase_12 AC 179 ms
10,880 KB
testcase_13 AC 192 ms
11,008 KB
testcase_14 AC 235 ms
11,008 KB
testcase_15 AC 233 ms
11,008 KB
testcase_16 AC 209 ms
10,880 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def Eratosthenes(n):
    is_prime=[True] * (n+1)
    is_prime[0]=False
    is_prime[1]=False
    for i in range(2,int(n**0.5)+1):
        if not is_prime[i]:
            continue
        for j in range(i*2,n+1,i):
            is_prime[j]=False
    return [i for i in range(n+1) if is_prime[i]]
n=int(input())
primes=Eratosthenes(n)
res=[False]*(n+1)
for i in range(2,n+1):
    if res[i]==False:
        for p in primes:
            if i+p>n:
                break
            res[i+p]=True
print('Win' if res[n] else 'Lose')
0