PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#TP0000053. Các đoạn chứa đúng k bội số của x (XK Segments)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Các đoạn chứa đúng k bội số của x (XK Segments)
XK Segments
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
You are given an array of positive integers and integers .
Consider an ordered pair of indices with such that . This pair is counted if the closed integer interval contains exactly integers divisible by . Pairs and are different when . Indices are allowed, and equal values at different positions still count separately.
Count all qualifying index pairs.
Input
- The first line contains three integers : the array length, divisor and required count of multiples.
- The second line contains exactly positive integers .
Output
Print one integer: the number of valid ordered index pairs.
Subtasks
- Subtask 1 (20 points): ; ; ; for every .
- Subtask 2 (30 points): ; ; ; for every .
- Subtask 3 (50 points): ; ; ; for every .
Examples
Input
4 2 1
1 3 5 7
Output
3
Explanation
The valid ordered index pairs are for containing , for containing , and for containing . Every other pair contains a different number of multiples of . The answer is .