結果

問題 No.713 素数の和
ユーザー maspymaspy
提出日時 2023-05-12 21:13:53
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 122 ms / 2,000 ms
コード長 486 bytes
コンパイル時間 135 ms
コンパイル使用メモリ 10,764 KB
実行使用メモリ 30,000 KB
最終ジャッジ日時 2023-08-19 03:33:53
合計ジャッジ時間 2,171 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 109 ms
29,764 KB
testcase_01 AC 111 ms
29,848 KB
testcase_02 AC 122 ms
29,920 KB
testcase_03 AC 118 ms
29,880 KB
testcase_04 AC 114 ms
29,724 KB
testcase_05 AC 113 ms
30,000 KB
testcase_06 AC 112 ms
29,896 KB
testcase_07 AC 111 ms
29,768 KB
testcase_08 AC 113 ms
29,792 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import numpy as np

N = int(read())

def make_prime(U):
    is_prime = np.zeros(U,np.bool_)
    is_prime[2] = 1
    is_prime[3::2] = 1
    M = int(U**.5)+1
    for p in range(3,M,2):
        if is_prime[p]:
            is_prime[p*p::p+p] = 0
    return is_prime, is_prime.nonzero()[0]

is_prime, primes = make_prime(10**5)
answer = primes[primes<=N].sum()
print(answer)
0