1192 : Big Matrix

时间限制Time Limit 1 Sec 内存限制Memory Limit 128 MB 提交次数Submitted 1279 Times 通过次数Solved 443 Times 标准评测Standard Judge

题目描述Description

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.

输入格式Input

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

输出格式Output

The sum mod by 109 + 7.

样例Sample

出题Author

CSGrandeur