题目链接: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. (转\整)UE4游戏优化 多人大地型游戏的优化(二)渲染线程的优化

    施主分享随缘,评论随心,@author:白袍小道 小道暗语: 1.因为小道这里博客目录没自己整,暂时就用随笔目录结构,所以二级目录那啥就忽略了.标题格式大致都是(原or转) 二级目录 (标题) 2.因 ...

  2. linux kernal oom killer 学习

    背景 我有2个定时任务,一个任务A是00:00开跑,另一个B是04:00开跑.正常情况下A会在2点多时候跑完,但是某一天因为某一步骤用的时间过久,导致4点还没跑完,这时候A内存占用大约在12g左右.4 ...

  3. 【转】mysql 计划事件

    转自:http://www.cnblogs.com/c840136/articles/2388512.html MySQL5.1.x版本中引入了一项新特性EVENT,顾名思义就是事件.定时任务机制,在 ...

  4. J2EE的十三个技术——EJB之消息驱动JMS

    JMS--Java Message Service JAVA的消息服务,消息可实现两端通信. 用于访问面向消息中间件的标准api,他提供与厂商无关的访问方法,以访问消息收发服务. 特点:即使其中一方不 ...

  5. 一个自动安装LNMP的简洁Shell脚本

    此脚本在生产服务器上使用了一年多,本脚本崇尚简单唯美,只需要一个脚本就可以在任何一台有网络的服务器上自动配置LNMP.本脚本会在脚本执行目录下,建packages目录用于存放LNMP所需要的软件.大家 ...

  6. InnoDB 存储引擎的线程与内存池

    InnoDB 存储引擎的线程与内存池   InnoDB体系结构如下: 后台线程: 1.后台线程的主要作用是负责刷新内存池中的数据,保证缓冲池中的内存缓存的是最近的数据: 2.另外,将以修改的数据文件刷 ...

  7. JAVA判断一个字符串里面有没有汉字

    private static boolean checkIfExistChineseCharacter(String s) { return !(s.length() == s.getBytes(). ...

  8. GYM - 101147 B.Street

    题意: 大矩形代表市场,大矩形当中有很多小矩形样式的伞.这些小矩形都贴着大矩形的左边或者右边且互不相交.小矩形以外的地方都是阳光.求经过大矩形时在阳光下的最短时间. 题解: 最短路的做法.起点和终点与 ...

  9. 《R语言实战》读书笔记--第二章 创建数据集

    2.1数据集的概念 变量的类型是不同的,比如标示符.日期变量.连续变量.名义变量.有序型变量等,记得数据挖掘导论中有专门的描述. R可以处理的数据类型包括了数值型.字符型.逻辑型.复数型(虚数).原生 ...

  10. Codeforces Round #356 (Div. 2) C

    C. Bear and Prime 100 time limit per test 1 second memory limit per test 256 megabytes input standar ...