結果

問題 No.1657 Sum is Prime (Easy Version)
ユーザー SidewaysOwlSidewaysOwl
提出日時 2021-08-27 22:09:53
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 578 ms / 2,000 ms
コード長 477 bytes
コンパイル時間 924 ms
コンパイル使用メモリ 86,196 KB
実行使用メモリ 154,740 KB
最終ジャッジ日時 2023-08-13 09:09:47
合計ジャッジ時間 15,529 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 525 ms
154,412 KB
testcase_01 AC 498 ms
154,416 KB
testcase_02 AC 546 ms
154,604 KB
testcase_03 AC 502 ms
154,164 KB
testcase_04 AC 495 ms
154,152 KB
testcase_05 AC 498 ms
154,312 KB
testcase_06 AC 529 ms
154,352 KB
testcase_07 AC 526 ms
153,928 KB
testcase_08 AC 494 ms
154,504 KB
testcase_09 AC 503 ms
154,540 KB
testcase_10 AC 502 ms
154,652 KB
testcase_11 AC 578 ms
154,488 KB
testcase_12 AC 547 ms
154,500 KB
testcase_13 AC 550 ms
154,380 KB
testcase_14 AC 546 ms
154,596 KB
testcase_15 AC 560 ms
154,212 KB
testcase_16 AC 542 ms
154,388 KB
testcase_17 AC 538 ms
154,740 KB
testcase_18 AC 547 ms
154,512 KB
testcase_19 AC 540 ms
154,384 KB
testcase_20 AC 551 ms
154,508 KB
testcase_21 AC 549 ms
154,536 KB
testcase_22 AC 542 ms
153,940 KB
testcase_23 AC 563 ms
154,740 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

l = [0] * (10 ** 7 + 1)
l[1]= 1
for i in range(2,int((10 ** 7) ** (1/2)) + 1):
    if l[i] == 0:
        n = i  * 2
        cnt = 2
        while n <= 10 ** 7:
            l[n] = 1
            cnt += 1
            n = i * cnt
L,R = map(int,input().split())
ans = 0
for i in range(1,10 ** 7 + 1):
    if L<= i <= R:
        if l[i] == 0:
            ans += 1
    if l[i] == 0:
        if i & 1:
            if L <= (i-1)//2 and (i+1)//2 <= R:
                ans += 1
print(ans)
0