#CCBOTPBA0000025. Số nguyên tố sinh đôi (Twin Prime Pairs)
Số nguyên tố sinh đôi (Twin Prime Pairs)
Twin Prime Pairs
Source: Phước Hưng OJ
Version: Phuoc Hung OJ Extended
Problem Statement
Count pairs (p,p+2) of primes where both elements lie in the inclusive interval [l,r], counted once by smaller member.
Input
Two integers l r.
Output
Number of twin prime pairs.
Subtasks
-
Subtask 1 (20%):
1 ≤ l ≤ r ≤ 100. -
Subtask 2 (30%):
1 ≤ l ≤ r ≤ 2000. -
Subtask 3 (50%):
1 ≤ l ≤ r ≤ 20000.
Examples
Example 1
Input:
2 13
Output:
3
Explanation: The three pairs are (3,5), (5,7), and (11,13).
Example 2
Input:
11 12
Output:
0
Explanation: Thirteen falls outside the interval.