A Math Problem
Time limit1sMemory limit512 MB
Given sequences a and b, count the pairs of sequences c and d whose LCM matrix equals the matrix of lcm(a_i, b_j), modulo 1e9+7.
- Level
Medium7 of 10
- Topics
- Number theory, Math, Combinatorics
- Solved
- No attempts yet
Problem
Zenyk is given a sequence of integers and a sequence of integers . Both sequences contain only positive integers. You built a matrix of size such that the element in the -th row and the -th column is the LCM (least common multiple) of and .
Now he wants to know how many pairs of sequences and produce the same matrix.
Input
The first line contains two integers and (). The second line contains integers . The third line contains integers ().
Output
Print the number of pairs modulo .