暴力求解——打表,暴力

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
解题思路:
就是一道水题,求的是矩形的个数,认真算个数,并摸出里面的规律就好了
程序代码:
#include<iostream>
using namespace std;
int main()
{
    int t,m,n;
    cin>>t;
    while(t--)
    {
       cin>>m>>n;
       cout<<n*(n+1)/2*m*(m+1)/2<<"
";
    }
    return 0;
}
版权声明:此代码归属博主, 请务侵权!
原文地址:https://www.cnblogs.com/www-cnxcy-com/p/4690368.html