标签:
Description
Input
Output
Sample Input
2 1 2 2 4
Sample Output
3 30
分析:本题的关键是找出规律,用公式表示出来,公式为s=n(n+1)/2*(m(m+1)/2),就是你分别按照行列计算矩形的个数(整体),然后相乘
AC代码:
#include <iostream>
using namespace std;
int main()
{
int t;
cin>>t;
while(t--)
{
int n,m,a,b,s;
a=0;
b=0;
s=1;
cin>>n>>m;
for(;n>0;n--)
a+=n;
for(;m>0;m--)
b+=m;
s=a*b;
cout<<s<<endl;
}
return 0;
}
标签:
原文地址:http://www.cnblogs.com/lbyj/p/5727281.html