2016huasacm暑假集训训练四 递推_C

题目链接:https://vjudge.net/contest/125308#problem/C

题意:给你一个高为n ,宽为m列的网格,计算出这个网格中有多少个矩形  这个题只要看两部分就行,先是横一排 是M长  最多m*(m+1)/2  个    再是竖一列 最多n*(n+1)/2个,

现在就把排和列拉伸,形成一个高为n*(n+1)/2,宽为m*(m+1)/2的网格,这样只要算下面积就行了

AC代码:

 1 #include<stdio.h>
 2 int main()
 3 {
 4    int t,x,y,t1;
 5    scanf("%d",&t);
 6    while(t--)
 7     {
 8       scanf("%d%d",&x,&y);
 9       t1 = x*(x+1)/2*y*(y+1)/2;
10       printf("%d
",t1);
11     }
12    return 0;
13 }
原文地址:https://www.cnblogs.com/LIUWEI123/p/5743514.html