結果

問題 No.1657 Sum is Prime (Easy Version)
ユーザー Akijin_007Akijin_007
提出日時 2023-05-11 19:18:12
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 148 ms / 2,000 ms
コード長 433 bytes
コンパイル時間 341 ms
コンパイル使用メモリ 87,052 KB
実行使用メモリ 92,092 KB
最終ジャッジ日時 2023-08-18 11:24:42
合計ジャッジ時間 4,257 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,452 KB
testcase_01 AC 71 ms
71,132 KB
testcase_02 AC 138 ms
91,684 KB
testcase_03 AC 77 ms
71,284 KB
testcase_04 AC 71 ms
71,624 KB
testcase_05 AC 74 ms
71,148 KB
testcase_06 AC 82 ms
76,504 KB
testcase_07 AC 80 ms
76,052 KB
testcase_08 AC 81 ms
76,544 KB
testcase_09 AC 79 ms
76,464 KB
testcase_10 AC 82 ms
76,308 KB
testcase_11 AC 85 ms
76,476 KB
testcase_12 AC 134 ms
91,536 KB
testcase_13 AC 110 ms
84,384 KB
testcase_14 AC 127 ms
89,292 KB
testcase_15 AC 126 ms
89,664 KB
testcase_16 AC 99 ms
82,008 KB
testcase_17 AC 99 ms
82,936 KB
testcase_18 AC 104 ms
83,536 KB
testcase_19 AC 132 ms
90,312 KB
testcase_20 AC 114 ms
85,916 KB
testcase_21 AC 148 ms
92,052 KB
testcase_22 AC 130 ms
92,000 KB
testcase_23 AC 138 ms
92,092 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#int(input())
#map(int, input().split())
#list(map(int, input().split()))

L, R = map(int, input().split())

p = [-1] * (2*R)

for i in range(2, R+1):
    if p[i] != -1:
        continue
    for j in range(2, R+1):
        if i*j >= 2*R:
            break
        p[i*j] = i
p[1] = 1

ans = 0
for i in range(L, R):
    if p[i] == -1:
        ans += 1
    if p[2*i+1] == -1:
        ans += 1

if p[R] == -1:
    ans += 1

print(ans)

0