結果

問題 No.1657 Sum is Prime (Easy Version)
ユーザー rlangevinrlangevin
提出日時 2022-12-31 22:17:57
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 466 bytes
コンパイル時間 375 ms
コンパイル使用メモリ 87,108 KB
実行使用メモリ 115,048 KB
最終ジャッジ日時 2023-08-17 21:27:50
合計ジャッジ時間 6,404 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 164 ms
114,628 KB
testcase_01 AC 163 ms
114,476 KB
testcase_02 AC 228 ms
114,976 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 167 ms
114,700 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 162 ms
114,528 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 173 ms
114,996 KB
testcase_12 AC 224 ms
115,048 KB
testcase_13 AC 193 ms
115,000 KB
testcase_14 AC 197 ms
115,044 KB
testcase_15 AC 199 ms
114,796 KB
testcase_16 AC 173 ms
114,972 KB
testcase_17 AC 167 ms
114,948 KB
testcase_18 AC 168 ms
114,792 KB
testcase_19 AC 224 ms
114,952 KB
testcase_20 AC 184 ms
114,972 KB
testcase_21 AC 242 ms
115,000 KB
testcase_22 AC 166 ms
114,640 KB
testcase_23 AC 174 ms
115,044 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from math import *


def Sieve(n):
    lst = [True] * (n + 1)
    S = set()
    for i in range(2, ceil(sqrt(n)) + 1):
        if lst[i]:
            for j in range(2 * i, n + 1, i):
                lst[j] = False
    for i in range(2, n + 1):
        if lst[i]:
            S.add(i)
    return S


L, R = map(int, input().split())
S = Sieve(2020202)
ans = 0
for i in range(L, R + 1):
    if i in S:
        ans += 1
    if 2 * i + 1 in S:
        ans += 1
print(ans)
0