結果

問題 No.1657 Sum is Prime (Easy Version)
ユーザー huka_hukahuka_huka
提出日時 2021-08-28 21:36:03
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 520 bytes
コンパイル時間 199 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 129,640 KB
最終ジャッジ日時 2024-05-01 16:34:39
合計ジャッジ時間 4,458 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
52,480 KB
testcase_01 AC 37 ms
52,224 KB
testcase_02 AC 266 ms
126,192 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 36 ms
52,224 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 48 ms
61,952 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 47 ms
62,208 KB
testcase_12 AC 268 ms
125,140 KB
testcase_13 AC 157 ms
108,076 KB
testcase_14 AC 231 ms
117,608 KB
testcase_15 AC 238 ms
118,252 KB
testcase_16 AC 129 ms
99,712 KB
testcase_17 AC 142 ms
102,912 KB
testcase_18 AC 149 ms
105,216 KB
testcase_19 AC 246 ms
122,616 KB
testcase_20 AC 182 ms
104,380 KB
testcase_21 AC 277 ms
129,640 KB
testcase_22 AC 270 ms
128,124 KB
testcase_23 AC 267 ms
127,512 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from bisect import bisect_left
def eratosthenes(n):
    Primes = []
    Is_prime = [True for _ in range(n+1)]
    Is_prime[0] = False
    Is_prime[1] = False
    for p in range(0, n+1):
        if not Is_prime[p]:
            continue
        Primes.append(p)
        for i in range(p*p, n+1, p):
            Is_prime[i] = False
    return Primes
l, r = map(int, input().split())
P = eratosthenes(r)[bisect_left(eratosthenes(r), l):]
Q = eratosthenes(2*r+1)[bisect_left(eratosthenes(2*r+1), 2*l+1):]
print(len(P)+len(Q))
0