結果

問題 No.1657 Sum is Prime (Easy Version)
ユーザー ああいいああいい
提出日時 2021-12-28 18:02:08
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,498 ms / 2,000 ms
コード長 349 bytes
コンパイル時間 216 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 35,280 KB
最終ジャッジ日時 2024-04-10 09:55:38
合計ジャッジ時間 14,044 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 28 ms
10,752 KB
testcase_01 AC 28 ms
10,752 KB
testcase_02 AC 1,353 ms
34,412 KB
testcase_03 AC 26 ms
10,752 KB
testcase_04 AC 27 ms
10,752 KB
testcase_05 AC 27 ms
10,752 KB
testcase_06 AC 33 ms
11,008 KB
testcase_07 AC 28 ms
10,752 KB
testcase_08 AC 30 ms
10,880 KB
testcase_09 AC 30 ms
10,880 KB
testcase_10 AC 32 ms
11,008 KB
testcase_11 AC 36 ms
10,880 KB
testcase_12 AC 1,301 ms
34,248 KB
testcase_13 AC 661 ms
27,056 KB
testcase_14 AC 1,023 ms
32,164 KB
testcase_15 AC 1,077 ms
32,328 KB
testcase_16 AC 435 ms
20,364 KB
testcase_17 AC 464 ms
21,428 KB
testcase_18 AC 499 ms
22,396 KB
testcase_19 AC 1,225 ms
32,932 KB
testcase_20 AC 730 ms
28,828 KB
testcase_21 AC 1,498 ms
35,280 KB
testcase_22 AC 1,176 ms
35,152 KB
testcase_23 AC 1,214 ms
34,872 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

C = 2 * R  + 2
dat = [0] * C
prime = set()

i = 2
while i < C:
    if dat[i] == 0:
        prime.add(i)
        for j in range(i * 2,C,i):
            dat[j] = 1
    i += 1
ans = 0
for A in range(L,R + 1):
    if A in prime:
        ans += 1
for A in range(L,R):
    if 2 * A + 1 in prime:
        ans += 1
print(ans)
0