sdau 省赛热身4 K - King's Sanctuary

sdau 省赛热身4   K - King's Sanctuary        

K - King's Sanctuary
Time Limit:1000MS     Memory Limit:65535KB     64bit IO Format:%lld & %llu

Description

The king found his adherents were building four sanctuaries for him. He is interested about the positions of the sanctuaries and wants to know whether they would form a parallelogram, rectangle, diamond, square or anything else.

Input

The first line of the input is T(1 <= T <= 1000), which stands for the number of test cases you need to solve.
Each case contains four lines, and there are two integers in each line, which shows the position of the four sanctuaries. And it is guaranteed that the positions are given clockwise. And it is always a convex polygon, if you connect the four points clockwise.

Output

For every test case, you should output "Case #t: " first, where t indicates the case number and counts from 1, then output the type of the quadrilateral.

Sample Input

5
0 0
1 1
2 1
1 0
0 0
0 1
2 1
2 0
0 0
2 1
4 0
2 -1
0 0
0 1
1 1
1 0
0 0
1 1
2 1
3 0

Sample Output

Case #1: Parallelogram
Case #2: Rectangle
Case #3: Diamond
Case #4: Square
Case #5: Others


几何水

题目大意:顺时针给出四个点(保证凸包),问这个四边形是平行四边形or矩形or菱形or正方形or Others。

题目分析:要判断它是什么形,应先理解这些“形”之间的关系,如下

平行四边形{
    矩形{
        正方形
        其它矩形
    }
    菱形{
        正方形
        其它菱形
    }
    其它平行四边形
}
Others
由于正方形在矩形里已经判断过一遍了,菱形里就不用管了。
code:
#include<cstdio>
using namespace std;
int main()
{
	int t,i,x1,x2,x3,x4,y1,y2,y3,y4;
	scanf("%d",&t);
	for(i=1;i<=t;i++)
	{
		scanf("%d%d%d%d%d%d%d%d",&x1,&y1,&x2,&y2,&x3,&y3,&x4,&y4);
		printf("Case #%d: ",i);
		//printf("%d %d %d %d\n",x2-x1,x3-x1,y2-y1,y3-y1);
		if(((x2-x1)==(x3-x4))&&((y2-y1)==(y3-y4)))
		{
			if((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1)==(x3-x2)*(x3-x2)+(y3-y2)*(y3-y2))
			{
				if((x2-x1)*(x4-x1)+(y2-y1)*(y4-y1)==0)printf("Square\n");
				else printf("Diamond\n");
			}
			else if(((x2-x1)*(x4-x1)+(y2-y1)*(y4-y1))==0)printf("Rectangle\n");
			else printf("Parallelogram\n");
		}
		else printf("Others\n");
	}
	return 0;
}








  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值