码迷,mamicode.com
首页 > 其他好文 > 详细

矩形A + B

时间:2015-08-01 15:42:20      阅读:109      评论:0      收藏:0      [点我收藏+]

标签:

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)

Total Submission(s): 5206    Accepted Submission(s): 4046


Problem 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<stdio.h>
int main()
{
	int i,j,k,c,n,m;
	scanf("%d",&n);
    __int64 a,b;
//	long long a,b;
  __int64 x[1000];
  x[1]=1;
  x[2]=3;
    for(i=3;i<111;i++)
    x[i]=x[i-1]+i;
	while(n--)
	{
		scanf("%I64d%I64d",&a,&b);
//		if(a<=0||b<=0)
//		{
//			printf("error\n");
//			continue;
//		}
		//printf("%lld\n",((a+1)*a/2)*(b*(b+1)/2));
		printf("%I64d\n",x[a]*x[b]);
	}
	return 0;
}


版权声明:本文为博主原创文章,未经博主允许不得转载。

矩形A + B

标签:

原文地址:http://blog.csdn.net/l15738519366/article/details/47186599

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!