#d1704. 合适数对(数据加强版)
合适数对(数据加强版)
Nice Pairs (Hard Version)
Problem Description
You are given a sequence of positive integers and a positive integer . Count how many pairs satisfy all of the following:
- ;
- there exists an integer such that .
Input Format
The first line contains two integers .
The second line contains positive integers .
Output Format
One integer: the number of valid pairs.
Sample Input
6 3
1 3 9 8 24 1
Sample Output
5
Constraints
For all test points, , , and .