Four Inages Strategy hdu 5206

4 篇文章 0 订阅

Four Inages Strategy

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 182    Accepted Submission(s): 66


Problem Description
Young F found a secret record which inherited from ancient times in ancestral home by accident, which named "Four Inages Strategy". He couldn't restrain inner exciting, open the record, and read it carefully. " Place four magic stones at four points as array element in space, if four magic stones form a square, then strategy activates, destroying enemy around". Young F traveled to all corners of the country, and have collected four magic stones finally. He placed four magic stones at four points, but didn't know whether strategy could active successfully. So, could you help him?
 

Input
Multiple test cases, the first line contains an integer  T (no more than  10000 ), indicating the number of cases. Each test case contains twelve integers  x1,y1,z1,x2,y2,z2,x3,y3,z3,x4,y4,z4,|x|,|y|,|z|100000 ,representing coordinate of four points. Any pair of points are distinct.
 

Output
For each case, the output should occupies exactly one line. The output format is Case # x ans , here  x  is the data number begins at  1 , if your answer is yes, ans  is Yes, otherwise  ans  is No.
 

Sample Input
  
  
2 0 0 0 0 1 0 1 0 0 1 1 0 1 1 1 2 2 2 3 3 3 4 4 4
 

Sample Output
  
  
Case #1: Yes

Case #2: No

就是求空间上的四个点看是否围成一个正方形。

先找邻边相等 再求对角线平方和为邻边的两倍~~

#include<stdio.h>
#include<string.h>
int main()
{
	int bbs;
	int x1,y1,z1,x2,y2,z2,x3,y3,z3,x4,y4,z4;
	scanf("%d",&bbs);
	int k=1;
	while(bbs--)
	{
		scanf("%d%d%d%d%d%d%d%d%d%d%d%d",&x1,&y1,&z1,&x2,&y2,&z2,&x3,&y3,&z3,&x4,&y4,&z4);
		int sum1=(x2-x1)*(x2-x1)+(y2-y1)*(y2-y1)+(z2-z1)*(z2-z1);
		int sum2=(x2-x3)*(x2-x3)+(y2-y3)*(y2-y3)+(z2-z3)*(z2-z3);
		int sum3=(x2-x4)*(x2-x4)+(y2-y4)*(y2-y4)+(z2-z4)*(z2-z4);
		
		int a,b;
		if(sum1==sum2||sum2==sum3||sum3==sum1)
		{
			if(sum1==sum2)
			{
				a=sum1;
				b=sum3;
			}
			else if(sum2==sum3)
			{
				a=sum2;
				b=sum1;
			}
			else 
			{
				a=sum3;
				b=sum2;
			}
			if(a*2==b)
			{
				printf("Case #%d: Yes\n",k++);
			}
			else printf("Case #%d: No\n",k++);
		}
		else 
		{
			printf("Case #%d: No\n",k++);
		}		
	}
	return 0;
}


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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值