hdu 5206 Four Inages Strategy
题目大意:
判断空间上4个点是否形成一个正方形
分析:
标称思想 : 在p2,p3,p4中枚举两个点作为p1的邻点,不妨设为pi,pj,然后判断p1pi与p1pj是否相等、互相垂直,然后由向量法,最后一个点坐标应该为pi+pj−p1,判断是否相等就好了。
我的思想 : 枚举了各种情况,4条边相等+有一个角是直角。后来想想,因为是在三维中,有可能4个点不共面,这点没想到,不过这道题AC了,估计数据水了
#include<cstdio>
#include<cstring>
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<queue>
#include<stack>
#include<vector>
#define eps 1e-9
#define maxn
using namespace std;
typedef long long LL;
struct Node
{
long long x,y,z;
};
Node p[];
double dist(int a,int b)
{
double cha1=(double)p[a].x-p[b].x;
double cha2=(double)p[a].y-p[b].y;
double cha3=(double)p[a].z-p[b].z;
return (sqrt(cha1*cha1+cha2*cha2+cha3*cha3));
}
int puan(int a,int b,int c)
{
LL x1=p[b].x-p[a].x;
LL y1=p[b].y-p[a].y;
LL z1=p[b].z-p[a].z; LL x2=p[b].x-p[c].x;
LL y2=p[b].y-p[c].y;
LL z2=p[b].z-p[c].z;
if(x1*x2+y1*y2+z1*z2==)
return ;
return ; }
int solve()
{
double tem1,tem2,tem3,tem4;
tem1=dist(,);
tem2=dist(,);
tem3=dist(,);
tem4=dist(,);
//printf("%lf %lf %lf %lf==\n",tem1,tem2,tem3,tem4);
if(fabs(tem1-tem2)<eps&&fabs(tem2-tem3)<eps&&fabs(tem3-tem4)<eps&&puan(,,))
return ;
tem1=dist(,);
tem2=dist(,);
tem3=dist(,);
tem4=dist(,);
if(fabs(tem1-tem2)<eps&&fabs(tem2-tem3)<eps&&fabs(tem3-tem4)<eps&&puan(,,))
return ;
tem1=dist(,);
tem2=dist(,);
tem3=dist(,);
tem4=dist(,);
if(fabs(tem1-tem2)<eps&&fabs(tem2-tem3)<eps&&fabs(tem3-tem4)<eps&&puan(,,))
return ;
tem1=dist(,);
tem2=dist(,);
tem3=dist(,);
tem4=dist(,);
// printf("%lf %lf %lf %lf==\n",tem1,tem2,tem3,tem4);
if(fabs(tem1-tem2)<eps&&fabs(tem2-tem3)<eps&&fabs(tem3-tem4)<eps&&puan(,,))
return ;
tem1=dist(,);
tem2=dist(,);
tem3=dist(,);
tem4=dist(,);
if(fabs(tem1-tem2)<eps&&fabs(tem2-tem3)<eps&&fabs(tem3-tem4)<eps&&puan(,,))
return ;
tem1=dist(,);
tem2=dist(,);
tem3=dist(,);
tem4=dist(,);
if(fabs(tem1-tem2)<eps&&fabs(tem2-tem3)<eps&&fabs(tem3-tem4)<eps&&puan(,,))
return ;
return ;
}
int main()
{
int t;
scanf("%d",&t);
for(int ii=; ii<=t; ii++)
{
for(int i=; i<=; i++)
scanf("%I64d %I64d %I64d",&p[i].x,&p[i].y,&p[i].z);
printf("Case #%d: ",ii);
if(solve())
printf("Yes\n");
else
printf("No\n"); }
return ;
}
hdu 5206 Four Inages Strategy的更多相关文章
- hdu 5206 Four Inages Strategy 判断是否是正方形
Four Inages Strategy Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem. ...
- 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 ...
- [BC]Four Inages Strategy(三维空间判断正方形)
题目连接 :http://bestcoder.hdu.edu.cn/contests/contest_showproblem.php?cid=577&pid=1001 题目大意:在三维空间中, ...
- BestCoder Round #38
1001 Four Inages Strategy 题意:给定空间的四个点,判断这四个点是否能形成正方形 思路:判断空间上4个点是否形成一个正方形方法有很多,这里给出一种方法,在p2,p3,p4中枚举 ...
- HDU 5973 Game of Taking Stones 威佐夫博弈+大数
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5973 Game of Taking Stones Time Limit: 2000/1000 MS ...
- HDU 1505 City Game (hdu1506 dp二维加强版)
F - City Game Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u Submi ...
- hdu 3032 Nim or not Nim? (SG函数博弈+打表找规律)
Nim or not Nim? Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u Sub ...
- HDU 4310 Hero (贪心算法)
A - Hero Time Limit:3000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64u Submit Sta ...
随机推荐
- ASP.NET MVC统一异常处理
前言: 今早看了篇文章:求知成瘾,却无作品 的思考:很有感触,发现原来自己也是这样,对每样东西都抱有很大的兴趣或者希望自己去学,一年后发现原来自己什么都是皮毛什么都不精!最终发现真正的大牛都是在某一个 ...
- jmeter内存溢出
当我用jmeter来测试elasticsearch性能的时候,发生过三种性质的内存溢出. 1. index 由于数据流过大,内存使用超过jmeter默认的上限,就溢出了. 用记事本打开jmeter.b ...
- wp8.1 Study1: 页面导航&页面间值传递
摘要:wp8.1与wp8中很多API是不一样了,wp8.1把以前wp7.x时的api去掉了,更多与win8.1的API相似.比如以下的页面导航和页面之间的值传递 1.页面导航 利用Frame.Navi ...
- Quartz 2D 图形上下文栈 矩阵 裁剪
Quartz 2D 图形上下文栈 矩阵 // // DJVIew.m // 图形上下文栈 // // Created by zjj on 15/6/30. // Copyright (c) 2015 ...
- K2 如何和 Java 做整合?
本文内容来自K2社区 问题:我们清楚K2 产品是基于.net 平台,我们有需求要将Java平台的表单和K2进行整合,使用K2.可以有什么方案建议? 专家解答: 这个需求也是比较常见的,以下是我的一些经 ...
- [网络技术][转]PPTP协议解析
PPTP协议大体上可以分为两部分:控制层连接和隧道,下面简要介绍两部分的功能.如果要详细了解PPTP协议请阅读RFC文档. 一. Control Connection Protol 控制层连接是基于T ...
- MicroPython开发板TPYBoard关于USB-HID的应用
USB-HID是Human Interface Device的缩写,属于人机交互操作的设备,如USB鼠标,USB键盘,USB游戏操纵杆,USB触摸板,USB轨迹球.电话拨号设备.VCR遥控等等设备. ...
- selectNodes
解析beans.xml的时候有时候找不到节点,把其他多余的删除之后就好了,不知道为什么.
- (转)xcode5.0.2下国际化图文解说
原文:http://blog.csdn.net/dragoncheng/article/details/6703311 xcode5.0.2下国际化图文解说 分类: ...
- Hash索引和B树索引
要知道磁盘结构优化访问的关键在于以block为单位(比如每次读取一个页面) 这两种索引差别也就在聚集到一个block的标准: B树聚集到一个block是因为关键字在一个范围内,关键字在block内的排 ...