Arrays and gcd
Time limit0.5sMemory limit128 MB
Count arrays arr with elements in [1, num] whose running gcd array equals the given array C, modulo 1e9+7.
- Level
Medium7 of 10
- Topics
- Number theory, Dynamic programming, Math, Combinatorics
- Solved
- No attempts yet
Problem
There are two integer arrays of size , called and . They satisfy the following relation.
Here is the greatest common divisor of and .
For example, gives .
Given the array , find the number of arrays that produce it, modulo (). Every element of is an integer between and .
Input
The first line contains two integers () and (), separated by a space.
The second line contains the elements of the array , that is , separated by spaces. ()
Output
Print the number of arrays that satisfy the conditions, modulo , on the first line.