Time Limit: 1 Sec Memory Limit: 256 MB
题目连接
http://acm.hdu.edu.cn/showproblem.php?pid=5206Description
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
Sample Input
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 #2: No
HINT
题意
小F在祖屋中意外发现一本上古时代传承下来的秘籍,名为《四象阵法》,他按捺不住内心的激动,翻开秘籍,一字一句地读了起来,“用四块元石作为阵基摆放在空间四处位置,如果四块元石形成一个正方形,则阵法激活,有杀敌困敌之效”,小F走遍五湖四海,终于集齐了四块元石,并将四块元石放置在四个坐标点上,可是他不知道阵法是否能够成功激活,于是,由你来告诉他答案。
题解:
一个正方形有六个距离,然后把对应的距离算出来,然后比一比就好啦~
代码:
//qscqesze #include <cstdio> #include <cmath> #include <cstring> #include <ctime> #include <iostream> #include <algorithm> #include <set> #include <vector> #include <sstream> #include <queue> #include <typeinfo> #include <fstream> #include <map> #include <stack> 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; }