LCC/Moose '20 Contest 5 J4 - Alan's Rectangle

View as PDF

Submit solution

Points: 7 (partial)
Time limit: 2.0s
Memory limit: 64M

Author:
Problem type

Alan has an N by M array of integers a_{ij}. Alan knows that he can make rectangles in the array and sum the elements contained in the rectangle, and calls it a "rectangle-sum". He wondered about sum of all rectangle-sums for all possible rectangles, but because Alan is too good at math, he already figured out the answer. Instead, he asks you to find the sum of all rectangle-sums for all rectangles where both dimensions are less than or equal to K (the length/width of a rectangle is how many elements it spans). Because this number can be very large, Alan asks for it modulo 10^9+7. Can you help Alan?

Input Specification

The first line will contain 3 integers N, M, K\ (1 \le N, M, K \le 10^9).

Output Specification

Output the answer to Alan's question, modulo 10^9+7.

Subtasks

Subtask 1 [20%]

0 < a_{ij} \le 1 \le N, M, K \le 1000

Subtask 2 [30%]

0 < a_{ij} \le 1 \le N, M, K \le 10^6

Subtask 3 [50%]

0 < a_{ij} \le 1

Sample Input

3 3 2

Sample Output

49

Comments

There are no comments at the moment.