Determinant Strikes Back
Time limit2sMemory limit512 MB
Find the determinant modulo 1e9+7 of an n by n matrix whose entries are a_i*b_j, with x added on the diagonal.
- Level
Medium7 of 10
- Topics
- Math, Matrix, Combinatorics, Implementation
- Solved
- No attempts yet
Problem
Dinara has an integer and two arrays of length , and . She builds an matrix as follows.
Find the determinant of modulo .
Input
The input consists of several test cases, terminated by end-of-file.
The first line of each test case contains two integers and . The second line contains integers . The third line contains integers .
Output
For each test case, print one integer, the result, on a line.
Constraints
- The sum of does not exceed .