题目大意:

判断空间上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的更多相关文章

  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 - 5206 Young F found a secret record which inherited from ancient times in ancestral home b ...

  3. HDU 5206 Four Inages Strategy 水题

    题目链接: hdu:http://acm.hdu.edu.cn/showproblem.php?pid=5206 bc(中文):http://bestcoder.hdu.edu.cn/contests ...

  4. [BC]Four Inages Strategy(三维空间判断正方形)

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

  5. BestCoder Round #38

    1001 Four Inages Strategy 题意:给定空间的四个点,判断这四个点是否能形成正方形 思路:判断空间上4个点是否形成一个正方形方法有很多,这里给出一种方法,在p2,p3,p4中枚举 ...

  6. HDU 5973 Game of Taking Stones 威佐夫博弈+大数

    题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5973 Game of Taking Stones Time Limit: 2000/1000 MS ...

  7. HDU 1505 City Game (hdu1506 dp二维加强版)

    F - City Game Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submi ...

  8. hdu 3032 Nim or not Nim? (SG函数博弈+打表找规律)

    Nim or not Nim? Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Sub ...

  9. HDU 4310 Hero (贪心算法)

    A - Hero Time Limit:3000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u Submit Sta ...

随机推荐

  1. ASP.NET MVC 上传大文件时404

    前一段时间会员的上传组件改用FLASH的swfupload来上传,既能很友好的显示上传进度,又能完全满足大文件的上传. 后来服务器升级到windows 2008,改为IIS7后,上传文件一旦超过30M ...

  2. Ubuntu里面的安装命令总结

    本人是新手中的新手,才开始用ubuntu.下面,总结一下安装软件的方法...... 0. 利用apt-get 其实,在ubuntu下安装软件的方法其实灰常简单.就是在终端里面输入: sudo apt- ...

  3. C# 文件与目录的基本操作(System.IO)

    1. 文件操作 /// <summary> /// 文件读写操作 /// 为简化代码供大家学习,暂不考虑捕捉异常 /// </summary> public partial c ...

  4. bzoj 1791: [Ioi2008]Island 岛屿

    #include<iostream> #include<cstdio> #define M 1000009 using namespace std; *M],cnt,n,hea ...

  5. PHPExcel 学习笔记

    首先到phpexcel官网上下载最新的phpexcel类,下周解压缩一个classes文件夹,里面包含了PHPExcel.php和PHPExcel的文件夹,这个类文件和文件夹是我们需要的,把class ...

  6. Hadoop 重启各个节点

    对于datanode可以在master中配置,然后在maste启动的时候,一并去启动这些节点 .对于死掉的节点,也可以通过以下命令启动 .重启挂掉的节点进入到 挂掉的机器 bin/hadoop-dae ...

  7. iis提示“另一个程序正在使用此文件,进程无法访问。(异常来自HRESULT:0x80070020)

    看看IIS的网站,惊人的发现default web site是停止状态.印象中没有停止它啊.右键->管理网站->启动.点击启动后居然弹出:“另一个程序正在使用此文件,进程无法访问.(异常来 ...

  8. 登陆sqlserver及修改端口号 (转)

    在一台计算机上面同时安装两个sql server数据库实例,第一次安装默认为机器名,端口号为1433 1.如果不知道服务器名,却想登陆的话可以直接输入127.0.0.1登陆之后,在新建查询中输入:SE ...

  9. LINQ基础 之 LINQ TO SQL (二)

    配置LINQ TO SQL 首先添加一个Linq to sql文件,以.dbml结尾的文件.无法把表拖拽到.dbml文件中,提示“所选对象使用不支持的数据提供程序” 解决方案 在服务器资源管理器中右键 ...

  10. 关于struts2拦截器获取页面参数

    package InterCeptor; import java.util.Iterator;import java.util.Map;import java.util.Map.Entry;impor ...