結果

問題 No.713 素数の和
ユーザー silversmithsilversmith
提出日時 2018-10-25 12:08:26
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
RE  
実行時間 -
コード長 511 bytes
コンパイル時間 92 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 11,008 KB
最終ジャッジ日時 2024-04-29 21:35:40
合計ジャッジ時間 859 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 31 ms
10,752 KB
testcase_01 RE -
testcase_02 RE -
testcase_03 AC 28 ms
10,752 KB
testcase_04 AC 29 ms
10,752 KB
testcase_05 AC 27 ms
10,752 KB
testcase_06 AC 28 ms
10,880 KB
testcase_07 AC 27 ms
10,752 KB
testcase_08 AC 29 ms
10,752 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import math

def primes(x):
	input_list=[False if i % 2==0 or i % 3 ==0 or i % 5 == 0 else True for i in range(x)]
	input_list[0] = input_list[1] = False
	input_list[2] = input_list[3] = input_list[5] = True
	sqrt = math.sqrt(x)

	for prime in range(3,x,2):
		if prime>=sqrt:
			break
		if not input_list[prime]:
			continue
		for s in range(prime ** 2,x,prime):
			input_list[s]=False

	return [i for i, b in enumerate(input_list) if b == True]

n = int(input())
prime_list = primes(n+1)
print(sum(prime_list))
0