結果

問題 No.1657 Sum is Prime (Easy Version)
ユーザー Mine
提出日時 2021-09-09 17:46:33
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 1,125 ms / 2,000 ms
コード長 468 bytes
コンパイル時間 332 ms
コンパイル使用メモリ 12,416 KB
実行使用メモリ 26,384 KB
最終ジャッジ日時 2024-12-30 21:06:18
合計ジャッジ時間 10,790 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

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