HDU 2524 矩形A + B

矩形A + B

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


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+1行格点中选取2行,再从m+1列格点中选取2列。
 
 1 #include <cstdio>
 2 #include <algorithm>
 3 using namespace std;
 4 
 5 int main()
 6 {
 7     int t,n,m;
 8     scanf("%d",&t);
 9     while(t--)
10     {
11         scanf("%d%d",&n,&m);
12         printf("%d\n",(n*(n+1)/2)*(m*(m+1)/2));
13     }
14 }

 

posted @ 2016-08-31 16:18  Cumulonimbus  阅读(133)  评论(0编辑  收藏  举报