結果
問題 |
No.1657 Sum is Prime (Easy Version)
|
ユーザー |
|
提出日時 | 2021-10-16 20:36:02 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 785 bytes |
コンパイル時間 | 314 ms |
コンパイル使用メモリ | 82,192 KB |
実行使用メモリ | 114,160 KB |
最終ジャッジ日時 | 2024-09-17 19:31:48 |
合計ジャッジ時間 | 4,891 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge6 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 15 WA * 6 |
ソースコード
#!/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)