結果

問題 No.1657 Sum is Prime (Easy Version)
ユーザー huka_huka
提出日時 2021-08-28 21:36:03
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 520 bytes
コンパイル時間 243 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 129,640 KB
最終ジャッジ日時 2024-11-21 21:48:22
合計ジャッジ時間 5,263 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 15 WA * 6
権限があれば一括ダウンロードができます

ソースコード

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