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

开始时间Start Time
2023-04-02 14:30:00
结束时间End Time
2023-04-02 19:30:00
当前时间Current Time
2026-05-06 21:20:22
比赛状态Contest Status
比赛类型Contest Type
公开Public
榜单状态Rank Status
公告 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 \times n, and parameters a_{1},a_{2},b_{1},b_{2}, the two matrices are defined as:

  • A(i, j)=i\times a_{1} + j\times a_{2}
  • B(i, j)=i\times b_{1} + j\times b_{2}

where i, j are 0, 1, 2, \cdots, n - 1.

Calculate the sum of all elements of C = AB.

输入格式Input

No more than 10 test cases. For each case, n a_{1} a_{2} b_{1} b_{2} are given.

  • 1 \leq n \leq 1000
  • 1 \leq a_{1}, a_{2}, b_{1}, b_{2} \leq 10^5

输出格式Output

The sum mod by 10^{9}+7.

样例Sample