結果

問題 No.1657 Sum is Prime (Easy Version)
ユーザー MineMine
提出日時 2021-09-09 17:46:33
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 963 ms / 2,000 ms
コード長 468 bytes
コンパイル時間 226 ms
コンパイル使用メモリ 10,896 KB
実行使用メモリ 23,700 KB
最終ジャッジ日時 2023-08-29 04:38:33
合計ジャッジ時間 9,399 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
7,996 KB
testcase_01 AC 15 ms
7,880 KB
testcase_02 AC 717 ms
23,112 KB
testcase_03 AC 18 ms
7,776 KB
testcase_04 AC 17 ms
7,816 KB
testcase_05 AC 18 ms
7,908 KB
testcase_06 AC 19 ms
8,200 KB
testcase_07 AC 18 ms
7,916 KB
testcase_08 AC 18 ms
7,964 KB
testcase_09 AC 19 ms
8,308 KB
testcase_10 AC 20 ms
8,332 KB
testcase_11 AC 23 ms
8,412 KB
testcase_12 AC 835 ms
22,932 KB
testcase_13 AC 413 ms
16,012 KB
testcase_14 AC 606 ms
20,844 KB
testcase_15 AC 668 ms
21,008 KB
testcase_16 AC 265 ms
13,816 KB
testcase_17 AC 252 ms
14,816 KB
testcase_18 AC 286 ms
15,320 KB
testcase_19 AC 833 ms
21,852 KB
testcase_20 AC 441 ms
17,568 KB
testcase_21 AC 963 ms
23,680 KB
testcase_22 AC 590 ms
23,700 KB
testcase_23 AC 615 ms
23,500 KB
権限があれば一括ダウンロードができます

ソースコード

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