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

时间:2022-12-16 09:13:01

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

K - King's SanctuaryTime Limit:1000MS     Memory Limit:65535KB     64bit IO Format:%lld & %lluSubmit Status

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;
}