hdu 5206 Four Inages Strategy 判断是否是正方形
Four Inages Strategy
Time Limit: 1 Sec Memory Limit: 256 MB
题目连接
http://acm.hdu.edu.cn/showproblem.php?pid=5206
Description
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=,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 判断是否是正方形的更多相关文章
- hdu 5206 Four Inages Strategy 计算几何
题目链接:HDU - 5206 Young F found a secret record which inherited from ancient times in ancestral home b ...
- HDU 5206 Four Inages Strategy 水题
题目链接: hdu:http://acm.hdu.edu.cn/showproblem.php?pid=5206 bc(中文):http://bestcoder.hdu.edu.cn/contests ...
- hdu 5206 Four Inages Strategy
题目大意: 判断空间上4个点是否形成一个正方形 分析: 标称思想 : 在p2,p3,p4中枚举两个点作为p1的邻点,不妨设为pi,pj,然后判断p1pi与p1pj是否相等.互相垂直,然后由向量法,最后 ...
- [BC]Four Inages Strategy(三维空间判断正方形)
题目连接 :http://bestcoder.hdu.edu.cn/contests/contest_showproblem.php?cid=577&pid=1001 题目大意:在三维空间中, ...
- POJ 1308&&HDU 1272 并查集判断图
HDU 1272 I - 小希的迷宫 Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64 ...
- hdu 1317 XYZZY【Bellheman_ford 判断正环小应用】
链接: http://acm.hdu.edu.cn/showproblem.php?pid=1317 http://acm.hust.edu.cn/vjudge/contest/view.action ...
- HDU 1269 迷宫城堡(判断有向图强连通分量的个数,tarjan算法)
迷宫城堡 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submis ...
- HDU 1756 Cupid's Arrow 判断点在多边形的内部
Cupid's Arrow Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Tot ...
- 小希的迷宫(HDU 1272 并查集判断生成树)
小希的迷宫 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submi ...
随机推荐
- ValueList用法
ValueList的OverView 概述 在很多情况下,使用JDBC是很繁琐的,有很多方法可以替换JDBC,比如JDO.Hibernate等. 即使在从service中接收POJO的List的解决方 ...
- PHP对象4: final 不允许重写方法或不允许继承类
final用在方法中,能继承方法, 不允许重写方法 final用在类声名中, 此类就不能继承 <?php class A{ final function say(){ say 'Ok<br ...
- thinkphp中的验证器
- shell source命令说明
当我修改了/etc/profile文件,我想让它立刻生效,而不用重新登录:这时就想到用source命令,如:source /etc/profile对source进行了学习,并且用它与sh 执行脚本进行 ...
- https、socket、http协议
一.https https 其实是由两部分组成:http+ssl(Secure Sockets Layer 安全套接层)/tls(Transport Layer Security 继任者安全传输层), ...
- input只读属性 设置和移除 选择数字
设置只读属性 $('#stage').attr("readonly", "readonly"); 移除 只读属性 $("input").r ...
- MySQL 和 Oracle 主键自增长
1.MySQL 1)建表 auto_increment:每插入一条数据,客户表(customers)的主键id就自动增1,如下所示 create table customers -- 创建客户表 ( ...
- entos 7 mailx配置163邮箱发送邮件
配置: .com .com set smtp-auth-user=wcczcl set smtp-auth=login set smtp-use-starttls set ssl-verify=ign ...
- Windows内核进程管理器解析
Windows内核是如何实现线程挂起的?如何实现线程挂载到进程的?如何实现杀死进程和线程的? 从源码分析一下,这些操作具体在源码上是如何实现的. 进程创建.线程切换.线程跨越CPU权限级.进程挂靠.杀 ...
- 几个python one-liner
生成斐波那契数列的前10个数,从1开始.若生成前n个,改为range(n-2).代码很简单: List = reduce(lambda x, y: x + [x[-1] + x[-2]], range ...