結果

問題 No.713 素数の和
ユーザー pofpof
提出日時 2019-07-16 14:47:50
言語 Python3
(3.11.6 + numpy 1.26.0 + scipy 1.11.3)
結果
AC  
実行時間 19 ms / 2,000 ms
コード長 296 bytes
コンパイル時間 153 ms
コンパイル使用メモリ 10,796 KB
実行使用メモリ 8,332 KB
最終ジャッジ日時 2023-08-20 12:34:44
合計ジャッジ時間 1,149 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 19 ms
8,192 KB
testcase_01 AC 17 ms
8,124 KB
testcase_02 AC 19 ms
8,072 KB
testcase_03 AC 19 ms
8,264 KB
testcase_04 AC 19 ms
8,332 KB
testcase_05 AC 19 ms
8,208 KB
testcase_06 AC 18 ms
8,100 KB
testcase_07 AC 17 ms
8,128 KB
testcase_08 AC 18 ms
8,320 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
if n ==1:
    print(0)
    import sys
    sys.exit()

a = {i for i in range(2, n+1)}
import math
q=set()
while True:
    p=sorted(list(a.difference(q)))[0]
    if p > int(math.sqrt(n)):
        break
    q.add(p)
    for i in range(2,n//p+1):
        a.discard(p*i)
print(sum(a))
0