結果

問題 No.1657 Sum is Prime (Easy Version)
ユーザー SidewaysOwlSidewaysOwl
提出日時 2021-08-27 22:09:53
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 415 ms / 2,000 ms
コード長 477 bytes
コンパイル時間 185 ms
コンパイル使用メモリ 82,576 KB
実行使用メモリ 143,540 KB
最終ジャッジ日時 2024-05-01 02:45:53
合計ジャッジ時間 10,153 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 358 ms
139,888 KB
testcase_01 AC 335 ms
139,812 KB
testcase_02 AC 394 ms
142,104 KB
testcase_03 AC 336 ms
140,416 KB
testcase_04 AC 339 ms
139,616 KB
testcase_05 AC 349 ms
139,756 KB
testcase_06 AC 373 ms
141,816 KB
testcase_07 AC 373 ms
140,172 KB
testcase_08 AC 344 ms
141,580 KB
testcase_09 AC 353 ms
142,668 KB
testcase_10 AC 379 ms
140,872 KB
testcase_11 AC 415 ms
141,576 KB
testcase_12 AC 388 ms
142,628 KB
testcase_13 AC 379 ms
142,412 KB
testcase_14 AC 392 ms
143,540 KB
testcase_15 AC 381 ms
142,688 KB
testcase_16 AC 386 ms
143,324 KB
testcase_17 AC 378 ms
142,384 KB
testcase_18 AC 376 ms
143,324 KB
testcase_19 AC 383 ms
142,048 KB
testcase_20 AC 380 ms
142,320 KB
testcase_21 AC 367 ms
142,380 KB
testcase_22 AC 405 ms
141,560 KB
testcase_23 AC 389 ms
143,280 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