結果

問題 No.713 素数の和
ユーザー kawacchukawacchu
提出日時 2019-10-17 21:08:38
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 18 ms / 2,000 ms
コード長 420 bytes
コンパイル時間 486 ms
コンパイル使用メモリ 10,640 KB
実行使用メモリ 7,968 KB
最終ジャッジ日時 2023-09-07 06:42:51
合計ジャッジ時間 1,475 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,832 KB
testcase_01 AC 16 ms
7,748 KB
testcase_02 AC 16 ms
7,960 KB
testcase_03 AC 16 ms
7,964 KB
testcase_04 AC 16 ms
7,920 KB
testcase_05 AC 18 ms
7,776 KB
testcase_06 AC 16 ms
7,876 KB
testcase_07 AC 16 ms
7,968 KB
testcase_08 AC 16 ms
7,824 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def sieve(n):
    "Return all primes <= n."
    np1 = n + 1
    s = list(range(np1)) # leave off `list()` in Python 2
    s[1] = 0
    sqrtn = int(round(n**0.5))
    for i in range(2, sqrtn + 1): # use `xrange()` in Python 2
        if s[i]:
            # next line:  use `xrange()` in Python 2
            s[i*i: np1: i] = [0] * len(range(i*i, np1, i))
    return filter(None, s)

print(sum(list(sieve(int(input())))))
0