結果

問題 No.1657 Sum is Prime (Easy Version)
ユーザー lloyzlloyz
提出日時 2021-12-01 23:56:00
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 370 bytes
コンパイル時間 302 ms
コンパイル使用メモリ 86,936 KB
実行使用メモリ 92,300 KB
最終ジャッジ日時 2023-09-18 10:00:52
合計ジャッジ時間 6,191 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 157 ms
91,532 KB
testcase_01 AC 165 ms
91,900 KB
testcase_02 AC 171 ms
91,500 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 159 ms
91,468 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 163 ms
91,528 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 168 ms
91,740 KB
testcase_12 AC 177 ms
91,564 KB
testcase_13 AC 175 ms
91,996 KB
testcase_14 AC 173 ms
91,708 KB
testcase_15 AC 176 ms
91,260 KB
testcase_16 AC 168 ms
91,808 KB
testcase_17 AC 171 ms
91,560 KB
testcase_18 AC 172 ms
91,808 KB
testcase_19 AC 182 ms
91,148 KB
testcase_20 AC 171 ms
91,548 KB
testcase_21 AC 186 ms
91,452 KB
testcase_22 AC 168 ms
91,116 KB
testcase_23 AC 171 ms
92,032 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

Prime = [True for _ in range(2 * 10**6 + 2)]
Prime[0] = Prime[1] = False
for i in range(2, 2 * 10**6 + 2):
    if not Prime[i]:
        continue
    for j in range(2 * i, 2 * 10**6 + 2, i):
        Prime[j] = False

l, r = map(int, input().split())
ans = 0
for i in range(l, r + 1):
    if Prime[i]:
        ans += 1
    if Prime[2 * i + 1]:
        ans += 1
print(ans)
0