結果

問題 No.1657 Sum is Prime (Easy Version)
ユーザー mesame3993mesame3993
提出日時 2021-09-16 00:01:44
言語 PyPy3
(7.3.13)
結果
RE  
実行時間 -
コード長 438 bytes
コンパイル時間 969 ms
コンパイル使用メモリ 87,064 KB
実行使用メモリ 294,908 KB
最終ジャッジ日時 2023-09-11 11:38:29
合計ジャッジ時間 4,947 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 76 ms
71,304 KB
testcase_01 AC 75 ms
71,356 KB
testcase_02 RE -
testcase_03 RE -
testcase_04 AC 74 ms
71,304 KB
testcase_05 AC 73 ms
71,428 KB
testcase_06 TLE -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import math

def prime_number(n):
	# n >= 2
	prime = []
	limit = math.sqrt(n)
	data = [i + 1 for i in range(1, n)]
	while True:
		p = data[0]
		if limit <= p:
			return prime + data
		prime.append(p)
		data = [e for e in data if e % p != 0]

l, r = map(int, input().split())
p = set(prime_number((r*(r+1) - l*(l-1)) // 2))

ans = 0
for i in range(l, r+1):
	tmp = 0
	for j in range(i, r+1):
		tmp += j
		if tmp in p:
			ans += 1
print(ans)
0