Efa has received an array of integers as her birthday gift. Her younger sister Tahia is fond of GCD (Greatest Common Divisor) and her elder sister Sifa likes LCM (Least Common Multiple). She wants to select a subarray from the array to please her sisters. She wants to make a choice such that when she multiplies the GCD of all elements in the chosen subarray with her favorite number , she will get the LCM of all elements in that subarray. Efa wants to know the number of subarrays she can select from the given array that satisfy this condition, can you help her with that?
Formally, you have to count the pair of integers (, ) such that and .
The first line of the input contains an integer () denoting the number of test cases. The description of the test cases follows.
The first line of each test case contains two integers and (, ) the size of Efa’s array and her favorite number.
The second line of each test case contains integers ().
Subtask 1 (10 Points): Sum of over all test cases doesn’t exceed .
Subtask 2 (20 Points): Sum of over all test cases doesn’t exceed .
Subtask 3 (70 Points): Sum of over all test cases doesn’t exceed .
For each test case, print a single integer the number of subarrays satisfying the condition.
Input | Output |
---|---|
3 5 1 3 1 3 3 2 5 2 1 2 1 2 1 5 3 3 9 5 4 7 | 6 10 1 |