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 <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=,f=;char ch=getchar();
while(ch<''||ch>''){if(ch=='-')f=-;ch=getchar();}
while(ch>=''&&ch<=''){x=x*+ch-'';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=;cas<=t;cas++)
{
node a[];
for(int i=;i<;i++)
cin>>a[i].x>>a[i].y>>a[i].z;
int flag=;
double t[];
int cnt=;
for(int i=;i<;i++)
for(int j=i+;j<;j++)
t[cnt++]=dis(a[i],a[j]);
sort(t,t+cnt);
if(t[]==t[]&&t[]==t[]&&t[]==t[]&&t[]*==t[]&&t[]==t[])
flag=;
if(flag)
printf("Case #%d: Yes\n",cas);
else
printf("Case #%d: No\n",cas);
}
return ;
}

hdu 5206 Four Inages Strategy 判断是否是正方形的更多相关文章

  1. hdu 5206 Four Inages Strategy 计算几何

    题目链接:HDU - 5206 Young F found a secret record which inherited from ancient times in ancestral home b ...

  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. [BC]Four Inages Strategy(三维空间判断正方形)

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

  5. POJ 1308&&HDU 1272 并查集判断图

      HDU 1272 I - 小希的迷宫 Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64 ...

  6. hdu 1317 XYZZY【Bellheman_ford 判断正环小应用】

    链接: http://acm.hdu.edu.cn/showproblem.php?pid=1317 http://acm.hust.edu.cn/vjudge/contest/view.action ...

  7. HDU 1269 迷宫城堡(判断有向图强连通分量的个数,tarjan算法)

    迷宫城堡 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submis ...

  8. HDU 1756 Cupid's Arrow 判断点在多边形的内部

    Cupid's Arrow Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Tot ...

  9. 小希的迷宫(HDU 1272 并查集判断生成树)

    小希的迷宫 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submi ...

随机推荐

  1. [Leetcode] Sum 系列

    Sum 系列题解 Two Sum题解 题目来源:https://leetcode.com/problems/two-sum/description/ Description Given an arra ...

  2. struct msghdr和struct cmsghdr【转载】

    理解struct msghdr当我第一次看到他时,他看上去似乎是一个需要创建的巨大的结构.但是不要怕.其结构定义如下:struct msghdr {    void         *msg_name ...

  3. Linux命令学习手册-route命令

    route [-CFvnee] route [-v]  [-A family] add [-net|-host] target [netmask Nm] [gw Gw] [metric N] [mss ...

  4. 大数据系列之kafka-java实现

    Java源码GitBub地址: https://github.com/fzmeng/kafka-demo 关于kafka安装步骤可见文章   http://www.cnblogs.com/cnmeng ...

  5. How to insert a segment of noise to music file

    如何向音频文件中插入噪声 为了研究噪声和音乐对EEG的的影响,实验前需要准备一段夹杂噪声的音乐. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ...

  6. oracle造成系统CPU过高的检查sql

    1. 根据占用CPU高的进程号来查询这个进程执行的SQL语句: CPU过高的进程号: #首先找到CPU过高的进程号 # top -bn1 是静态找到占用最高的进程 [root@localhost ~] ...

  7. covariance matrix 和数据分布情况估计

    how to get data covariance matrix: http://stattrek.com/matrix-algebra/covariance-matrix.aspx meaning ...

  8. jquery.query.js 插件(示例及简单应用) —— html之间传值

    帮助文档 var url = location.search; > "?action=view&section=info&id=123&debug&te ...

  9. 用tomcat配置https自签名证书,解决 ios7.1以上系统, 苹果inHouse发布

    用tomcat配置https自签名证书,解决 ios7.1以上系统苹果inHouse发布不能下载安装的问题教程,话说,我其实最讨厌配置某某环境了,因为某一个小环节一旦出错,你的所有工作往往会功亏一篑, ...

  10. 使用php扩展mcrypt实现AES加密

    AES(Advanced Encryption Standard,高级加密标准)是美国联邦政府采用的一种区块加密标准.这个标准用来替代原先的DES,已经被多方分析且广为全世界所使用.Rijndael是 ...