#SP0000225. Phân tích thị trường phức tạp (Complex Market Analysis)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Phân tích thị trường phức tạp (Complex Market Analysis)
Complex Market Analysis
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
William has an array of positive integers and a jump size . Consider pairs of positive integers satisfying .
For a pair, take the array elements at positions . Because , this sequence contains at least two elements.
Count the pairs for which the product of all selected values is prime. Array indices start at .
Input
The first line contains integers and . The second line contains integers .
Output
Print the number of valid pairs with prime product and .
Subtasks
-
Subtask 1 (20 points): ; for every .
-
Subtask 2 (30 points): ; for every .
-
Subtask 3 (50 points): ; for every .
Examples
Input
7 3
10 2 1 3 1 19 3
Output
2
Explanation
For and , pair uses and , with prime product . Pair uses and , with prime product . All other candidate pairs contain a composite factor, at least two factors greater than , or have product . Therefore the answer is 2.