Determinant of the GCD Matrix
Time limit1sMemory limit128 MB
Given a divisor-closed set of numbers, compute the determinant of the pairwise-gcd matrix modulo 1e9+7 using Smith's theorem via Euler's totient function.
- Level
Medium6 of 10
- Topics
- Number theory, Math, Combinatorics
- Solved
- No attempts yet
Problem
A set is closed under divisors if, for every , every divisor of also satisfies .
From a divisor-closed set , build the greatest common divisor matrix where . Write a program that computes the determinant of this matrix.
Input
The first line contains the number of test cases . For each test case, the first line contains the number of elements () of the set . The next line contains the elements (, and each is an integer).
Output
For each test case, print the determinant of the greatest common divisor matrix of the given set modulo .