题目大意:

判断空间上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. spring的依赖注入DI(IOC)

    1.手动注入 (1)set注入 public class UserService { private UserDao userDao; public void setUserDao(UserDao d ...

  2. 统计类别数量并且使用pyplot画出柱状图

    从数据库中读取数据,具体操作为: # -*- coding: utf-8 -*- from numpy import * import numpy as np import pandas as pd ...

  3. 常用三方,Reachability 检测网络连接

    常用三方 Reachability 检 测网络连接 用来检查网络连接是否可用:包括WIFI和 WWAN(3G/EDGE/CDMA等)两种工作模式. 可以从Apple网站下载到: http://deve ...

  4. <input type="hidden" id="haha" name="wang" value="xiaodong" />

    jsp中一个隐藏的文本框,文本框里的值是:xiaodong id属性和name属性:就是在JavaScript中或者控制器中根据id或name属性取它的value的值 开发人员所需要,又不想让用户看到 ...

  5. wechat

  6. 读写其他应用程序的SharedPreference

    2013-12-28 18:03:40 要读写其他应用的SharedPreference,前提是创建该SharedPreference的程序指定相应的可读或可写的权限, 如下: private voi ...

  7. include指令和<jsp:include>标准动作

    利用JSP的包含机制,可以有效的避免重复,把可重用的部分独立出去,使用include把它们包含到当前文件.JSP有两种包含机制:include指令和<jsp:include>标准动作. 1 ...

  8. Android设计画面中有EditText时取消启动时自动获得焦点调用系统输入法的方法

    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools= ...

  9. Android 之 JSON操作

    Android默认已经集成了操作JSON相关的API,如下所示: 也可以不使用JSON工具类,直接使用字符串拼接. 注意:可以使用字符串来构造JSONArray和JSONObject,这就是JSON解 ...

  10. linux exec用法总结

    Linux中exec的用法总结 先总结一个表: exec命令 作用 exec ls 在shell中执行ls,ls结果显示结束后不返回原来的的目录中,而是/(根目录) exec <file 将fi ...