結果

問題 No.1657 Sum is Prime (Easy Version)
コンテスト
ユーザー Mine
提出日時 2021-09-09 17:46:33
言語 Python3
(3.14.3 + numpy 2.4.4 + scipy 1.17.1)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
AC  
実行時間 713 ms / 2,000 ms
コード長 468 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 604 ms
コンパイル使用メモリ 20,700 KB
実行使用メモリ 30,712 KB
最終ジャッジ日時 2026-06-04 09:34:04
合計ジャッジ時間 9,707 ms
ジャッジサーバーID
(参考情報)
judge2_1 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

l, r = map(int, input().split())
def Sieve_of_Eratosthenes(maxA):
    lst = [None]*(maxA+1)
    lst[0] = False
    lst[1] = False
    for i in range(2, maxA+1):
        if lst[i] is None:
            for g in range(i, maxA+1, i):
                if lst[g] is None:
                    lst[g] = False
            lst[i] = True
    return lst

lst = Sieve_of_Eratosthenes(2*r+1)
ans = int(lst[r])
for i in range(l, r):
    ans += lst[i]
    ans += lst[2*i+1]

print(ans)
0