[Solution] Count GCD Codeforces Solution
You are given two integers and and an array of integers. For each it holds that .
Your task is to count the number of different arrays of length such that:
- for each , and
- for each .
Here deontes the greatest common divisor (GCD) of integers .
Since this number can be too large, print it modulo .
Each test consist of multiple test cases. The first line contains a single integer () — the number of test cases. The description of test cases follows.
The first line of each test case contains two integers and (, ) — the length of the array and the maximum possible value of the element.
The second line of each test case contains integers () — the elements of the array .
It is guaranteed that the sum of across all test cases doesn't exceed .
For each test case, print a single integer — the number of different arrays satisfying the conditions above. Since this number can be large, print it modulo .
In the first test case, the possible arrays are:
- ;
- ;
- .
In the second test case, the only array satisfying the demands is .
In the third test case, it can be proven no such array exists
No comments:
Post a Comment