4592: Big Matrix
内存限制:128 MB
时间限制:1 S
标准输入输出
题目类型:传统
评测方式:Special Judge
上传者:
提交:1
通过:0
题目描述
Given two matrices A and B with the same size n × n, and parameters a1, a2, b1, b2, the two matrices are defined as:
- A(i,j) = i × a1 + j × a2
- B(i,j) = i × b1 + j × b2
where i, j are 0, 1, 2, ⋯, n − 1.
Calculate the sum of all elements of C = AB.
输入格式
No more than 10 test cases. For each case, n a1 a2 b1 b2 are given.
- 1 ≤ n ≤ 1000
- 1 ≤ a1, a2, b1, b2 ≤ 105
输出格式
The sum mod by 109 + 7.
输入样例 复制
2 1 1 1 1
4 1 2 3 4
输出样例 复制
10
3504