PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#SP0000054. Số giống 2017 (2017-like Number)
HỌC THEO LỘ TRÌNH
2 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Số giống 2017 (2017-like Number)
2017-like Number
Source: AtCoder
Version: Phuoc Hung OJ Extended
Problem Statement
A 2017-like number is an odd integer such that both and are prime. You are given queries, each containing two odd integers . For every query, count the 2017-like integers in the inclusive interval .
Input
The first line contains integer . Each of the following lines contains two odd integers with .
Output
Print exactly lines; line is the count of 2017-like numbers in .
Subtasks
- Subtask 1 (20 points): ; ; both are odd for every .
- Subtask 2 (30 points): ; ; both are odd for every .
- Subtask 3 (50 points): ; ; both are odd for every .
Examples
Input
1
3 7
Output
2
Explanation
The query covers . The number qualifies because is prime; qualifies because is prime. The number does not qualify since is composite. Hence print 2.