1015: 湖南省第十八届大学生计算机程序设计竞赛(HNCPC2022) - Semilive

开始 Start
 
结束 End
 
当前 Now
 
状态 Status
类型 Type
公开Public
榜单 Rank
公告 Announcement
暂无公告No announcement

D (1192) : Big Matrix

时间限制Time Limit 1 Sec 内存限制Memory Limit 128 MB 提交次数Submitted 226 Times 通过次数Solved 78 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