PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#SP0000099. Đếm số nguyên tố qua nhiều truy vấn (Số nguyên tố (OLP 10 - 2019))
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Đếm số nguyên tố qua nhiều truy vấn (Số nguyên tố (OLP 10 - 2019))
Số nguyên tố (OLP 10 - 2019)
Source: LQDOJ
Version: Phuoc Hung OJ Extended
Problem Statement
A mathematician has questions. Question asks how many prime numbers belong to the inclusive interval . A prime is an integer greater than having exactly two positive divisors. Answer all questions in their original order.
Input
The first line contains . Each of the next lines contains for question .
Output
Print lines. Line is the count of primes in .
Subtasks
- Subtask 1 (20 points): ; ; .
- Subtask 2 (30 points): ; ; .
- Subtask 3 (50 points): ; ; .
Examples
Input
2
1 50
10000000 10000050
Output
15
1
Explanation
The interval has primes: . The interval contains only one prime, . Hence the answers are and .