矩形A + B
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 5982 Accepted Submission(s): 4610
Problem Description
给你一个高为n ,宽为m列的网格,计算出这个网格中有多少个矩形,下图为高为2,宽为4的网格.
![](https://i-blog.csdnimg.cn/blog_migrate/30eb0263b48b7de077ccf5a73574b88d.jpeg)
Input
第一行输入一个t, 表示有t组数据,然后每行输入n,m,分别表示网格的高和宽 ( n < 100 , m < 100).
Output
每行输出网格中有多少个矩形.
Sample Input
2 1 2 2 4
Sample Output
3 30题图,宽可以分别为1 2 3 4 即4+3+2+1=10;高可以为 1 2 即2+1=3;总个数为宽的类别×高的类别。代码 :#include<cstdio> int main() { int t,n,m; int a,b; scanf("%d",&t); while(t--) { scanf("%d%d",&n,&m); a=n*(n+1)/2; b=m*(m+1)/2; printf("%d\n",a*b); } return 0; }