PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#SP0000058. Đếm đoạn có ít nhất K số nguyên tố (Frequent Prime Ranges)
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 đoạn có ít nhất K số nguyên tố (Frequent Prime Ranges)
Frequent Prime Ranges
Source: SPOJ
Version: Phuoc Hung OJ Extended
Problem Statement
Consider the consecutive integers . A contiguous interval is defined by integer endpoints with . It is K-frequent if it contains at least prime numbers. Count the endpoint pairs that satisfy this condition. Two intervals are distinct if at least one endpoint differs. For , every interval qualifies.
Input
One line contains two integers and .
Output
Print one integer: the number of qualifying intervals .
Subtasks
- Subtask 1 (20 points): ; .
- Subtask 2 (30 points): ; .
- Subtask 3 (50 points): ; .
Examples
Input
5 2
Output
4
Explanation
Between and , the primes are . The intervals containing at least two primes are , , and . No other interval qualifies, so print 4.