http://acm.hdu.edu.cn/showproblem.php?pid=2524
矩形A + B
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 4254 Accepted Submission(s): 3286
Problem Description
给你一个高为n ,宽为m列的网格,计算出这个网格中有多少个矩形,下图为高为2,宽为4的网格.

Input
第一行输入一个t, 表示有t组数据,然后每行输入n,m,分别表示网格的高和宽 ( n < 100 , m < 100).
Output
每行输出网格中有多少个矩形.
Sample Input
2 1 2 2 4
Sample Output
3 30
思路:
或者直接有公式:(m+1)*m/2 *(n+1)*n/2
</pre><h1 style="color: rgb(26, 92, 200);"><span style="font-size:14px;"></span></h1><h1 style="color: rgb(26, 92, 200);"><span style="font-size:14px;"><span style="color:#000000;"></span></span><pre class="cpp" name="code">#include<stdio.h>
#include<string.h>
int main()
{
int T,N,M,sum,i,j;
scanf("%d",&T);
while(T--)
{
scanf("%d %d",&N,&M);
for(i=0,sum=0;i<N;i++)
for(j=0;j<M;j++)
sum+=(N-i)*(M-j);
printf("%d\n",sum);
}
return 0;
}