博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
hdu 5206 Four Inages Strategy 判断是否是正方形
阅读量:6797 次
发布时间:2019-06-26

本文共 2949 字,大约阅读时间需要 9 分钟。

Four Inages Strategy

Time Limit: 1 Sec  Memory Limit: 256 MB

题目连接

http://acm.hdu.edu.cn/showproblem.php?pid=5206

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

HINT

 

题意

小F在祖屋中意外发现一本上古时代传承下来的秘籍,名为《四象阵法》,他按捺不住内心的激动,翻开秘籍,一字一句地读了起来,“用四块元石作为阵基摆放在空间四处位置,如果四块元石形成一个正方形,则阵法激活,有杀敌困敌之效”,小F走遍五湖四海,终于集齐了四块元石,并将四块元石放置在四个坐标点上,可是他不知道阵法是否能够成功激活,于是,由你来告诉他答案。

题解:

一个正方形有六个距离,然后把对应的距离算出来,然后比一比就好啦~

代码:

 

//qscqesze#include 
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
typedef long long ll;using namespace std;//freopen("D.in","r",stdin);//freopen("D.out","w",stdout);#define sspeed ios_base::sync_with_stdio(0);cin.tie(0)#define maxn 200001#define mod 10007#define eps 1e-9//const int inf=0x7fffffff; //无限大const int inf=0x3f3f3f3f;/*int buf[10];inline void write(int i) { int p = 0;if(i == 0) p++; else while(i) {buf[p++] = i % 10;i /= 10;} for(int j = p-1; j >=0; j--) putchar('0' + buf[j]); printf("\n");}*///**************************************************************************************inline ll read(){ int x=0,f=1;char ch=getchar(); while(ch<'0'||ch>'9'){ if(ch=='-')f=-1;ch=getchar();} while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();} return x*f;}struct node{ ll x,y,z;};ll dis(node a,node b){ return (a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y)+(a.z-b.z)*(a.z-b.z);}int main(){ int t; t=read(); for(int cas=1;cas<=t;cas++) { node a[4]; for(int i=0;i<4;i++) cin>>a[i].x>>a[i].y>>a[i].z; int flag=0; double t[10]; int cnt=0; for(int i=0;i<4;i++) for(int j=i+1;j<4;j++) t[cnt++]=dis(a[i],a[j]); sort(t,t+cnt); if(t[1]==t[0]&&t[1]==t[2]&&t[2]==t[3]&&t[3]*2==t[4]&&t[4]==t[5]) flag=1; if(flag) printf("Case #%d: Yes\n",cas); else printf("Case #%d: No\n",cas); } return 0;}

 

转载地址:http://oxego.baihongyu.com/

你可能感兴趣的文章
php把数据转换为json格式
查看>>
Java线程(学习整理)--2---加入另一个线程join
查看>>
replace into 浅析之一
查看>>
软件工程15 个人阅读作业2—提出问题
查看>>
Windows Azure Traffic Manager的新的管理API
查看>>
1.5站立会议之个人
查看>>
remote机制的AdditionalFields
查看>>
MySQL 常用内置函数与所有内置函数
查看>>
bzoj千题计划105:bzoj3503: [Cqoi2014]和谐矩阵(高斯消元法解异或方程组)
查看>>
Mybatis学习(4)输入映射、输出映射、动态sql
查看>>
java设计模式-策略模式
查看>>
iOS随笔记录
查看>>
objective-c面向对象
查看>>
Windows 7下Git SSH 创建Key【待解决?】
查看>>
阿里云服务器Linux CentOS安装配置(七)域名解析
查看>>
最长公共前缀---简单
查看>>
课程引言作业一
查看>>
like 大数据字段 查询慢
查看>>
JSON 数据格式
查看>>
Django----解决跨域
查看>>