You are given an array and you need to find number of tripets of indices such that the elements at those indices are in geometric progression for a given common ratio and .
For example, . If , we have and at indices and .
Complete the countTriplets function in the editor below. It should return the number of triplets forming a geometric progression for a given as an integer.
countTriplets has the following parameter(s):
The first line contains two space-separated integers and , the size of and the common ratio.
The next line contains space-seperated integers .
Return the count of triplets that form a geometric progression.
Sample Input 0
1 2 2 4
Sample Output 0
There are triplets in satisfying our criteria, whose indices are and
Sample Input 1
1 3 9 9 27 81
Sample Output 1
The triplets satisfying are index , , , , and .
Sample Input 2
1 5 5 25 125
Sample Output 2
The triplets satisfying are index , , , .