问题2484--Skewness

2484: Skewness

时间限制: 1 Sec  内存限制: 128 MB
提交: 1  解决: 1
[提交] [状态] [讨论版] [命题人:]

题目描述

Bobo has a matrix A with n rows and n columns.
For submatrix with upper-left corner (x1, y1) and lower-right corner (x2, y2) (1≤ x1≤ x2≤ n, 1≤ y1 ≤y2 ≤n), 
he defined its skewness S(x1, y1, x2, y2) =(ΣiΣj Ai,j)3.i=x1 to x2, j=y1 to y2.
Bobo would like to know the sum of skewness of all submatrices modulo (109 + 7).

输入

The input contains zero or more test cases and is terminated by end-of-file. For each test case:
The first line contains an integer n.
The i-th of following n lines contains n integers Ai,1,Ai,2, . . . ,Ai,n.
• 1≤ n≤1000
• 0≤Ai,j≤109
• The number of test cases does not exceed 10.

输出

For each case, output an integer which denotes the sum.

样例输入

2
0 1
1 0
3
0 1 0
1 1 0
1 0 1

样例输出

14
448

来源/分类


[提交] [状态]