結果

問題 No.1657 Sum is Prime (Easy Version)
ユーザー huka_hukahuka_huka
提出日時 2021-08-28 21:39:52
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 279 ms / 2,000 ms
コード長 520 bytes
コンパイル時間 308 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 129,364 KB
最終ジャッジ日時 2024-05-01 16:38:39
合計ジャッジ時間 5,162 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
52,608 KB
testcase_01 AC 37 ms
51,840 KB
testcase_02 AC 246 ms
125,684 KB
testcase_03 AC 37 ms
51,968 KB
testcase_04 AC 36 ms
52,480 KB
testcase_05 AC 37 ms
52,480 KB
testcase_06 AC 47 ms
61,568 KB
testcase_07 AC 41 ms
60,672 KB
testcase_08 AC 42 ms
61,568 KB
testcase_09 AC 43 ms
61,952 KB
testcase_10 AC 45 ms
62,208 KB
testcase_11 AC 48 ms
62,464 KB
testcase_12 AC 252 ms
125,516 KB
testcase_13 AC 148 ms
107,956 KB
testcase_14 AC 224 ms
117,264 KB
testcase_15 AC 231 ms
118,428 KB
testcase_16 AC 121 ms
99,716 KB
testcase_17 AC 134 ms
102,912 KB
testcase_18 AC 140 ms
105,708 KB
testcase_19 AC 235 ms
122,660 KB
testcase_20 AC 177 ms
104,448 KB
testcase_21 AC 259 ms
129,364 KB
testcase_22 AC 259 ms
127,880 KB
testcase_23 AC 279 ms
127,724 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