HDU 5206 Four Inages Strategy 水题
题目链接:
hdu:http://acm.hdu.edu.cn/showproblem.php?pid=5206
bc(中文):http://bestcoder.hdu.edu.cn/contests/contest_showproblem.php?cid=577&pid=1001
题解:
先判四点是否共面,然后再判断一下四条邻边相等并且两条对角线相等就可以了。
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std; const int maxn=+;
typedef long long LL; struct Point {
LL x,y,z;
Point(LL x,LL y,LL z):x(x),y(y),z(z){}
Point(){};
friend Point operator - (const Point& p1,const Point& p2){
return Point(p1.x-p2.x,p1.y-p2.y,p1.z-p2.z);
}
} pt[]; typedef Point Vector; Vector cross(const Vector& v1,const Vector& v2){
return Vector(v1.y*v2.z-v1.z*v2.y,v2.x*v1.z-v1.x*v2.z,v1.x*v2.y-v1.y*v2.x);
} LL dis(int i,int j) {
Point pt1=pt[i];
Point pt2=pt[j];
return (pt1.x-pt2.x)*(pt1.x-pt2.x)+(pt1.y-pt2.y)*(pt1.y-pt2.y)+(pt1.z-pt2.z)*(pt1.z-pt2.z);
} bool judge(){
Vector v1=pt[]-pt[];
Vector v2=pt[]-pt[];
Vector v3=pt[]-pt[];
Vector cr1=cross(v1,v2);
Vector cr2=cross(v2,v3);
Vector ret=cross(cr1,cr2);
if(!ret.x&&!ret.y&&!ret.z) return true;
return false;
} int main() {
int tc,kase=;
scanf("%d",&tc);
while(tc--) {
for(int i=; i<; i++) scanf("%lld%lld%lld",&pt[i].x,&pt[i].y,&pt[i].z);
int flag=;
if(judge()) {
for(int i=; i<; i++) {
for(int j=; j<; j++) {
if(j!=i) {
for(int k=; k<; k++) {
if(k!=j&&k!=i) {
for(int l=; l<; l++) {
if(l!=i&&l!=j&&l!=k) {
if(dis(i,j)==dis(j,k)&&dis(j,k)==dis(k,l)&&dis(k,l)==dis(l,i)&&dis(i,k)==dis(j,l)) {
flag=;
}
}
}
}
}
}
}
}
}
printf("Case #%d: ",++kase);
if(flag) {
puts("Yes");
} else {
puts("No");
}
}
return ;
}
/*
1 0 0 0 1 0 0 -1 0 0 0 1
1 0 0 0 1 0 0 -1 0 -1 0 0
*/
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
题目大意: 判断空间上4个点是否形成一个正方形 分析: 标称思想 : 在p2,p3,p4中枚举两个点作为p1的邻点,不妨设为pi,pj,然后判断p1pi与p1pj是否相等.互相垂直,然后由向量法,最后 ...
- HDU 5538 L - House Building 水题
L - House Building Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.ph ...
- HDU 5578 Friendship of Frog 水题
Friendship of Frog Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.ph ...
- HDU 5590 ZYB's Biology 水题
ZYB's Biology Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid ...
- hdu 1005:Number Sequence(水题)
Number Sequence Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)T ...
- hdu 1018:Big Number(水题)
Big Number Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total ...
- hdu 2041:超级楼梯(水题,递归)
超级楼梯 Time Limit: / MS (Java/Others) Memory Limit: / K (Java/Others) Total Submission(s): Accepted Su ...
随机推荐
- jdk8新特性-stream
一.什么是流stream 1.可理解为高级版本的 Iterator 不是集合元素,它不是数据结构并不保存数据,它是有关算法和计算的. 2.单向,不可往复 数据只能遍历一次,遍历过一次后即用尽了,就好比 ...
- cookie,session,token
发展史 1.很久很久以前,Web 基本上就是文档的浏览而已, 既然是浏览,作为服务器, 不需要记录谁在某一段时间里都浏览了什么文档,每次请求都是一个新的HTTP协议, 就是请求加响应, 尤其是我不用 ...
- 搭建lamp或者lnmp环境,本地链接mysql报错解决方法
报错:1130-host...is not allowed to connect to this mysql server 解决方法: 1.改表法 可能是你的账号不允许从远程登录,这个时候只要进入服务 ...
- 请简述以下两个for 循环的优缺点
今天笔试时候遇到一个问题,找到相似的. ; i<N; i++) { if (condition) DoSomething(); else DoOtherthing(); } if (condit ...
- 快速理解python2中的编码问题
# -*- coding:utf-8 -*- ''' python2 中的字符编码有str和unicode(字符串类型的名字) str类型字符串类型在内存中存储的是bytes数据 Unicode类型字 ...
- go语言带cookie的net客户端请求与[]byte转string
前些日子参加了一个叫Advent of Code的编程大赛,每天一道题,快活似神仙.这每道题都有自己的拼图数据输入puzzle input,要做题就需要用到该数据,把数据复制过来感觉又太麻烦,于是就兴 ...
- js scroll nav
http://jsfiddle.net/cse_tushar/Dxtyu/141/http://ironsummitmedia.github.io/startbootstrap-scrolling-n ...
- 20155231 实验三 敏捷开发与XP实践
20155231 实验三 敏捷开发与XP实践 实验内容 XP基础 XP核心实践 相关工具 实验要求 没有Linux基础的同学建议先学习<Linux基础入门(新版)><Vim编辑器&g ...
- Wcf服务测试自带工具
Visual Studio 安装包文件夹 \Common7\IDE\WcfTestClient.exe
- QT-2D编程
QT-[转]2D编程 Qt中提供了强大的2D绘图系统,可以使用相同的API在屏幕上和绘图·设备上进行绘制,主要基于QPainter.QPainterDevice和QPainterEngine这3个类. ...