3106: Matrix

时间限制:1000 ms 内存限制:128 MB
上传者:
提交:12 通过:6

题目描述


we often use a tow-dimensional prefix sum to speed up sub-matrix summation. The problem is described as follows:

For matrix $a$ of the n-row m-column, $a_{i,j}$ represents the number of column j in row i. Now give the sub-matrix upper-left $(x_0,y_0)$ and bottom-right $(x_1,y_1)$; you need to quicky work out: 

$$\sum_{i=x_0}^{x_1}\sum_{j=y_0}^{y_1} a_{i,j}$$ 

To solve this problem, we can introduce a two-dimensional array b, where $b_{i_0,j_0} = \sum_{i=1}^{i_0}\sum_{j=1}^{j_0}a_{i,j}$,so there is the following calculation: 

$$\sum_{i=x_0}^{x_1}\sum_{j=y_0}^{y_1} a_{i,j} = b_{x_1,y_1}-b_{x_1,y_{0}}-b_{x_{0},{y_1}}+b_{x_{0},y_{0-1}}$$ 

After learning this, hyd asked his good friend lwq such a question: given a matrix of n-row m-columns, ask how many sub-matrices are sumd up to be integer times k. lwq is busy doing his homework, can you help hime copy with hyd?


输入格式

The first line contains three integers n, m, k ($1\le n,m\le 200$,$1\le k\le 10^9$), representing the number of rows and columns of the matrix, respectively.

In the next n rows, each line has m numbers $a_{i,j} (0 \le a_{i,j} \le 10^9)$ separated by spaces.

输出格式


An integer that represents the number of sub-matrixes that satisfy the meaning of the question.

输入样例 复制

3 4 7
4 5 3 5
4 4 4 1
5 2 5 4

输出样例 复制

4