結果

問題 No.1657 Sum is Prime (Easy Version)
ユーザー siro53siro53
提出日時 2021-08-27 22:51:40
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 106 ms / 2,000 ms
コード長 460 bytes
コンパイル時間 308 ms
コンパイル使用メモリ 82,268 KB
実行使用メモリ 78,028 KB
最終ジャッジ日時 2024-05-01 03:38:38
合計ジャッジ時間 3,428 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 87 ms
75,288 KB
testcase_01 AC 89 ms
75,788 KB
testcase_02 AC 101 ms
77,784 KB
testcase_03 AC 87 ms
74,812 KB
testcase_04 AC 92 ms
75,344 KB
testcase_05 AC 90 ms
75,080 KB
testcase_06 AC 93 ms
77,260 KB
testcase_07 AC 88 ms
75,288 KB
testcase_08 AC 92 ms
75,388 KB
testcase_09 AC 94 ms
76,132 KB
testcase_10 AC 90 ms
77,140 KB
testcase_11 AC 94 ms
77,948 KB
testcase_12 AC 99 ms
77,336 KB
testcase_13 AC 96 ms
77,400 KB
testcase_14 AC 95 ms
76,920 KB
testcase_15 AC 100 ms
77,364 KB
testcase_16 AC 96 ms
77,588 KB
testcase_17 AC 91 ms
78,028 KB
testcase_18 AC 93 ms
76,992 KB
testcase_19 AC 103 ms
76,700 KB
testcase_20 AC 98 ms
77,352 KB
testcase_21 AC 106 ms
77,316 KB
testcase_22 AC 92 ms
76,128 KB
testcase_23 AC 94 ms
77,112 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

MAX = 10**6 * 2
table = [True] * (MAX + 1)
table[0] = table[1] = False

for i in range(2, MAX + 1):
    if i * i > MAX:
        break
    if table[i] == False:
        continue
    for j in range(i*2, MAX+1, i):
        table[j] = False

ans = 0
L, R = map(int, input().split())
for a in range(L, R+1):
    if table[a]:
        ans += 1
for a in range(L, R):
    b = a + 1
    if table[a + b]:
        ans += 1
print(ans)
0