CF567C Geometric Progression
Description
Polycarp loves geometric progressions very much. Since he was only three years old, he loves only the progressions of length three. He also has a favorite integer $ k $ and a sequence $ a $ , consisting of $ n $ integers.
He wants to know how many subsequences of length three can be selected from $ a $ , so that they form a geometric progression with common ratio $ k $ .
A subsequence of length three is a combination of three such indexes $ i_{1},i_{2},i_{3} $ , that $ 1
Input Format
The first line of the input contains two integers, $ n $ and $ k $ ( $ 1
Output Format
Output a single number — the number of ways to choose a subsequence of length three, such that it forms a geometric progression with a common ratio $ k $ .
Explanation/Hint
In the first sample test the answer is four, as any of the two 1s can be chosen as the first element, the second element can be any of the 2s, and the third element of the subsequence must be equal to 4.