矩形A + B

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 5198    Accepted Submission(s): 4041


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   |   We have carefully selected several similar problems for you:  2521 2523 2503 2526 2522 
//网上有两种理解: 但都是找  长和宽 。 (m+(m-1 )+(m-2)+.....1)*(n + (n-1) + (n-2) +(n-3) + ....1) == C(N+1,2)*C(M+1, 2).  呵呵,比赛的时候做不出来, 看完题解果然就出答案啊。 
                                                      ----, 学到知识就好。
 1 #include <cstdio>
 2 #include <cstring>
 3 #include <iostream>
 4 using namespace std;
 5 int main()
 6 {
 7     int n, m, t;
 8     scanf("%d", &t);
 9     while(t--)
10     {
11         scanf("%d %d", &n, &m);
12         printf("%d\n",n*(n+1)*m*(m+1)/4);
13     }
14     return 0;
15 }

 

 
posted on 2015-08-01 14:49  cleverbiger  阅读(188)  评论(0编辑  收藏  举报