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 ...
随机推荐
- C#在线更新程序[下载程序、解压缩程序、控制台程序]
[1]下载文件 using System;using System.Collections.Generic;using System.Linq;using System.Text;using Syst ...
- iOS产品开发流程
iOS产品开发流程 a.产品经理做需求调研,确定产品需求,编写需求文档 b.产品人员完成产品原型 c.产品经理召开会议(产品,UI,UE,开发,测试,服务器) d.设计人员根据原型设计出一系列UI界面 ...
- HDU 3533 Escape bfs 难度:1
http://acm.hdu.edu.cn/showproblem.php?pid=3533 一道普通的bfs,但是由于代码实现出了bug还是拖了很久甚至对拍了 需要注意的是: 1.人不能经过炮台 2 ...
- dancing link模板
#include<cstdio> #include<iostream> #include<cstring> #include<algorithm> #i ...
- lucene4.7学习总结
花了一段时间学习lucene今天有时间把所学的写下来,网上有很多文章但大部分都是2.X和3.X版本的(当前最新版本4.9),希望这篇文章对自己和初学者有所帮助. 学习目录 (1)什么是lucene ( ...
- Quartz 2D 图形上下文栈 矩阵 裁剪
Quartz 2D 图形上下文栈 矩阵 // // DJVIew.m // 图形上下文栈 // // Created by zjj on 15/6/30. // Copyright (c) 2015 ...
- Spring学习笔记之初始化和销毁方法的调用次序
Multiple lifecycle mechanisms configured for the same bean, with different initialization methods, a ...
- 国产ProcessOn和国外gliffy的对比区别【原创】
之前一直在用国外的作图工具gliffy,不足之处gliffy是英文的,很多国内相关从业者使用起来就有一定门槛,今天我给大家再推荐一款比gliffy更方便的作图工具ProcessOn,除了绘制UML建模 ...
- iOS开发中的远程推送实现(最新,支持iOS9)
我的个人项目<丁丁印记>中加入了远程推送功能,按照操作说明去做还是比较容易实现的,但是学的不够不系统,而且iOS8之后的推送和之前的版本是有所不同的,因此这篇文章希望总结一下最新的iOS推 ...
- (转)UIApplication sharedApplication详细解释-IOS
iPhone应用程序是由主函数main启动,它负责调用UIApplicationMain函数,该函数的形式如下所示: int UIApplicationMain ( int argc, char *a ...