結果

問題 No.1657 Sum is Prime (Easy Version)
ユーザー tcltktcltk
提出日時 2021-10-16 20:36:02
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 785 bytes
コンパイル時間 156 ms
コンパイル使用メモリ 81,780 KB
実行使用メモリ 113,600 KB
最終ジャッジ日時 2023-10-17 22:17:20
合計ジャッジ時間 5,972 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 127 ms
85,940 KB
testcase_01 AC 126 ms
85,936 KB
testcase_02 AC 271 ms
111,940 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 127 ms
85,936 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 140 ms
86,620 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 139 ms
88,264 KB
testcase_12 AC 257 ms
111,676 KB
testcase_13 AC 190 ms
100,084 KB
testcase_14 AC 233 ms
108,408 KB
testcase_15 AC 239 ms
108,664 KB
testcase_16 AC 172 ms
96,716 KB
testcase_17 AC 181 ms
98,220 KB
testcase_18 AC 184 ms
99,428 KB
testcase_19 AC 255 ms
110,412 KB
testcase_20 AC 210 ms
103,264 KB
testcase_21 AC 263 ms
113,600 KB
testcase_22 AC 274 ms
113,600 KB
testcase_23 AC 265 ms
113,436 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/env python3
# from typing import *

import sys
import io
import math
import collections
import decimal
import itertools
import bisect
import heapq


def input():
    return sys.stdin.readline()[:-1]


# sys.setrecursionlimit(1000000)

# _INPUT = """1 4
# """
# sys.stdin = io.StringIO(_INPUT)

INF = 10**10

def get_primes(N):
    a = [True] * (N + 1)
    l = []
    for n in range(2, N + 1):
        if a[n]:
            l.append(n)
            for i in range(n+n, N + 1, n):
                a[i] = False
    return l

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

primes = get_primes(2*R+2)

i1 = bisect.bisect_left(primes, L)
j1 = bisect.bisect_left(primes, R+1)
i2 = bisect.bisect_left(primes, 2*L+1)
j2 = bisect.bisect_left(primes, 2*R+1+1)
ans = (j1 - i1) + (j2 - i2)
print(ans)

0