题目链接:HDU - 5206

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.
题意描述:给出四个三维坐标位置,判断这四个点能否构成一个正方形。
算法分析:比赛的时候刚开始想到正方形边边相等,然后四角90度,这样的方法搞到一半的时候想了想有点麻烦呀,后来仔细想了想,突然意识到正方形里每个顶点到其他三个顶点距离的关系:对角线距离*对角线距离=2*边*边。然后就OK啦。
 #include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<vector>
#include<queue>
#define inf 0x7fffffff
using namespace std;
typedef long long LL;
const LL maxn=+; LL n,m;
struct Point
{
LL x,y,z;
Point (LL x=,LL y=,LL z=):x(x),y(y),z(z){}
}a,b,c,d;
typedef Point Vector; double Dot(Vector A,Vector B) {return A.x*B.x + A.y*B.y; }
double Length(Vector A) {return sqrt(Dot(A,A)); }
double angle(Vector A,Vector B) {return acos(Dot(A,B)/Length(A)/Length(B)); } LL dis(Point A,Point B)
{
LL xx=(A.x-B.x)*(A.x-B.x);
LL yy=(A.y-B.y)*(A.y-B.y);
LL zz=(A.z-B.z)*(A.z-B.z);
return xx+yy+zz;
} int main()
{
int t,ncase=;
scanf("%d",&t);
while (t--)
{
scanf("%I64d%I64d%I64d%I64d%I64d%I64d%I64d%I64d%I64d%I64d%I64d%I64d",
&a.x,&a.y,&a.z,&b.x,&b.y,&b.z,&c.x,&c.y,&c.z,&d.x,&d.y,&d.z);
//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 flag=;
LL len,len2,len3;
len=dis(a,b) ;len2=dis(a,c) ;len3=dis(a,d) ;
if ((len==len2&&len3==len+len2)||(len==len3&&len2==len+len3)||(len2==len3&&len==len2+len3))
flag++;
len=dis(b,a) ;len2=dis(b,c) ;len3=dis(b,d) ;
if ((len==len2&&len3==len+len2)||(len==len3&&len2==len+len3)||(len2==len3&&len==len2+len3))
flag++;
len=dis(c,a) ;len2=dis(c,b) ;len3=dis(c,d) ;
if ((len==len2&&len3==len+len2)||(len==len3&&len2==len+len3)||(len2==len3&&len==len2+len3))
flag++;
len=dis(d,a) ;len2=dis(d,b) ;len3=dis(d,c) ;
if ((len==len2&&len3==len+len2)||(len==len3&&len2==len+len3)||(len2==len3&&len==len2+len3))
flag++;
if (flag==) printf("Case #%d: Yes\n",ncase++);
else printf("Case #%d: No\n",ncase++);
}
return ;
}
 
 

hdu 5206 Four Inages Strategy 计算几何的更多相关文章

  1. hdu 5206 Four Inages Strategy 判断是否是正方形

    Four Inages Strategy Time Limit: 1 Sec  Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem. ...

  2. HDU 5206 Four Inages Strategy 水题

    题目链接: hdu:http://acm.hdu.edu.cn/showproblem.php?pid=5206 bc(中文):http://bestcoder.hdu.edu.cn/contests ...

  3. hdu 5206 Four Inages Strategy

    题目大意: 判断空间上4个点是否形成一个正方形 分析: 标称思想 : 在p2,p3,p4中枚举两个点作为p1的邻点,不妨设为pi,pj,然后判断p1pi与p1pj是否相等.互相垂直,然后由向量法,最后 ...

  4. hdu 2393:Higher Math(计算几何,水题)

    Higher Math Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total ...

  5. HDU 5839 Special Tetrahedron (计算几何)

    Special Tetrahedron 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5839 Description Given n points ...

  6. [BC]Four Inages Strategy(三维空间判断正方形)

    题目连接 :http://bestcoder.hdu.edu.cn/contests/contest_showproblem.php?cid=577&pid=1001 题目大意:在三维空间中, ...

  7. hdu 5784 How Many Triangles 计算几何,平面有多少个锐角三角形

    How Many Triangles 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5784 Description Alice has n poin ...

  8. HDU 4606 Occupy Cities (计算几何+最短路+二分+最小路径覆盖)

    Occupy Cities Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)To ...

  9. HDU 6351暴力枚举 6354计算几何

    Beautiful Now Time Limit: 5000/2500 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)T ...

随机推荐

  1. unity值得推荐的网址

    免费字体下载网站:http://www.dafont.com/ 免费声音文件下载网站:http://freesound.org/          http://incompetech.com/mus ...

  2. Abstract Factory 抽象工厂(创建型模式)

    1.常规的对象创建方法(以更换QQ空间主题为例) (这里的常规对象指的是由于业务需求,当前实例化的对象有可能被其他相似的对象(有着共同的特性)所取代,例如更换手机铃声:一首歌取代另一首歌(词,曲,和声 ...

  3. HDU 4107 Gangster(线段树 特殊懒惰标记)

    两种做法. 第一种:标记区间最大值和最小值,若区间最小值>=P,则本区间+2c,若区间最大值<P,则本区间+c.非常简单的区间更新. 最后发一点牢骚:最后query查一遍就行,我这个2B竟 ...

  4. HDU 4731 Minimum palindrome (找规律)

    M=1:aaaaaaaa…… M=2:DFS+manacher, 暴出N=1~25的最优解,找规律.N<=8的时候直接输出,N>8时,头两个字母一定是aa,剩下的以aababb循环,最后剩 ...

  5. BETA(1)

    目录 组员情况 组员1(组长):胡绪佩 组员3:庄卉 组员4:家灿 组员5:凯琳 组员6:翟丹丹 组员7:何家伟 组员8:政演 组员9:黄鸿杰 组员10:刘一好 组员11:何宇恒 展示组内最新成果 团 ...

  6. 【Python】- 第一行跟第二行的写法

    第一行:目的就是指出,你想要你的这个文件中的代码用什么可执行程序去运行它,就这么简单 #!/usr/bin/python:告诉操作系统执行这个脚本的时候,调用/usr/bin下的python解释器: ...

  7. [poj] 1235 Farm Tour || 最小费用最大流

    原题 费用流板子题. 费用流与最大流的区别就是把bfs改为spfa,dfs时把按deep搜索改成按最短路搜索即可 #include<cstdio> #include<queue> ...

  8. [codeforces] 526D [51nod] 1554 欧姆诺姆和项链

    原题 KMP 方法一: 听说是ex-kmp--来自学姐 ex-kmp是处理两个串s和t之间,t的每一个后缀在s中的最长前缀的长度的一个算法. 它很像manacher(至少我和学姐这么认为),记录了一个 ...

  9. 部分浏览器上a标签包裹的dom元素显示不正常

    在苹果和部分安卓机上出现,pc端和chrome浏览器响应式设计里怎么样也不会出现的访问后a标签包裹的dom元素显示不正常a标签内的hr元素颜色显示不正常hr水平线的颜色被 bootstrap的css的 ...

  10. hdu 6119 …&&百度之星 T6

    小小粉丝度度熊 Problem Description 度度熊喜欢着喵哈哈村的大明星——星星小姐. 为什么度度熊会喜欢星星小姐呢? 首先星星小姐笑起来非常动人,其次星星小姐唱歌也非常好听. 但这都不是 ...