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 ...
随机推荐
- 关于HTML5应用开发功耗调优化小结
HTML5的优化一直是困扰我的难题,特别是在移动端开发游戏和应用,所以对此进行了一些总结: 功耗优化点介绍 在移动设备中主要的功耗点在: 1. 网络的传输, 不管是3G网络还是WiFi传输都是移动设备 ...
- HDU 4405 Aeroplane chess 概率DP 难度:0
http://acm.hdu.edu.cn/showproblem.php?pid=4405 明显,有飞机的时候不需要考虑骰子,一定是乘飞机更优 设E[i]为分数为i时还需要走的步数期望,j为某个可能 ...
- 使用windows服务和MSMQ和进行日志管理(解决高并发问题)
首先,建立一个windows服务项目 然后进行设计视图 在工作区空白处右属,添加一个安装项目 然后就可以写我们的代码了,我们的服务需要实时监视MSMQ的队列中有没有记录,如果有,就向数据库中插入 核心 ...
- Memcached 及 Redis 架构分析和比较
Memcached和Redis作为两种Inmemory的key-value数据库,在设计和思想方面有着很多共通的地方,功能和应用方面在很多场合下(作为分布式缓存服务器使用等) 也很相似,在这里把两者放 ...
- [开发笔记]-sqlite数据库在使用时遇到的奇葩问题记录
有时候做些简单的项目一般都会选择sqlite数据库,优点有很多,这里就不详细说了. 在此主要记录一些平时在使用时遇到的问题及解决方法.希望能对大家有所帮助. --------------------- ...
- Android 之 JSON操作
Android默认已经集成了操作JSON相关的API,如下所示: 也可以不使用JSON工具类,直接使用字符串拼接. 注意:可以使用字符串来构造JSONArray和JSONObject,这就是JSON解 ...
- OpenCV函数解读之groupRectangles
不管新版本的CascadeClassifier,还是老版本的HAAR检测函数cvHaarDetectObjects,都使用了groupRectangles函数进行窗口的组合,其函数原型有以下几个: C ...
- 速度!!!抢KIS英文版(多设备版)3年激活码
活动地址 http://promo.kaspersky.com/wvu直接打不开,需要用 US 的 在 线 代 理,暂时提供1个(204.12.228.235)可以绕过第一步邮箱验证注意:3年版多设备 ...
- 移动设备和SharePoint 2013 - 第4部分:定位
博客地址:http://blog.csdn.net/foxdave 原文地址 在该系列文章中,作者展示了SharePoint 2013最显著的新功能概观--对移动设备的支持. 该系列文章: 移动设备和 ...
- 第一课 Hello
using System; using Android.App; using Android.Content; using Android.Runtime; using Android.Views; ...