結果

問題 No.713 素数の和
ユーザー caleicalei
提出日時 2020-01-24 15:45:20
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 17 ms / 2,000 ms
コード長 401 bytes
コンパイル時間 242 ms
コンパイル使用メモリ 10,728 KB
実行使用メモリ 7,940 KB
最終ジャッジ日時 2023-10-12 04:09:25
合計ジャッジ時間 901 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,828 KB
testcase_01 AC 16 ms
7,804 KB
testcase_02 AC 16 ms
7,852 KB
testcase_03 AC 17 ms
7,940 KB
testcase_04 AC 16 ms
7,800 KB
testcase_05 AC 17 ms
7,792 KB
testcase_06 AC 16 ms
7,776 KB
testcase_07 AC 15 ms
7,816 KB
testcase_08 AC 15 ms
7,780 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# yukicoder No.713 素数の和 2020/01/24

def sieve(n):
    if n<2:return [0]
    end=int(pow(n,0.5))+1
    is_prime=[True]*(n+1)
    is_prime[0]=False
    is_prime[1]=False

    for i in range(2,end+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())
ans=sum(sieve(n))
print(ans)
0