这篇博客是从旧博客 WordPress 迁移过来,内容可能存在转换异常。
传送门:http://acm.hdu.edu.cn/showproblem.php?pid=2524
仔细分析下就明白了, 首先考虑行 : 1格 : n个 2格: n-1个 …. 共有 sum1 = n * (n+1) /2 种
同理 列 也是 sum2 = m * ( m + 1 ) / 2 种方式,
组合起来就是 : sum1 * sum2 种 方式
#include
int main()
{
int t,n,m;
scanf("%d",&t;);
while(t--)
{
scanf("%d %d",&n;,&m;);
printf("%d\n",n*(n+1)*m*(m+1)/4);
}
return 0;
}