矩形A + B
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 4026 Accepted Submission(s): 3116
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
Source
Recommend
gaojie
思路:很好推就是高为n宽为m的矩形的数目就等于(1+2+3+……+x)*(1+2+3……+y)
ac代码
#include<stdio.h>
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
int x,y;int sum1,sum2;
scanf("%d%d",&x,&y);
sum1=x*(1+x)*1/2;
sum2=y*(1+y)*1/2;
printf("%d\n",sum1*sum2);
}
}