#3725

Count Ways to Choose Coprime Integers from Rows

candidate master · 1480 · lc hard +32 · 48.3% accepted · 63 likes · top 34%

Description

Given an m x n matrix mat of positive integers, return the number of ways to select exactly one element from each row such that the GCD of all selected values is 1, modulo 109 + 7.

Code

1
2
3