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 ...
随机推荐
- ElasticSearch优化系列五:机器设置(硬盘、CPU)
硬盘对集群非常重要,特别是建索引多的情况.磁盘是一个服务器最慢的系统,对于写比较重的集群,磁盘很容易成为集群的瓶颈. 如果可以承担的器SSD盘,最好使用SSD盘.如果使用SSD,最好调整I/O调度算法 ...
- C语言中的强制类型转换
先直接放程序吧,后面还有总结. -------------------------------------------start------------------------------------ ...
- PTA基础编程题目集6-2多项式求值(函数题)
本题要求实现一个函数,计算阶数为n,系数为a[0] ... a[n]的多项式f(x)=∑i=0n(a[i]×xi) 在x点的值. 函数接口定义: double f( int n, dou ...
- Java编码算法和摘要算法
编码算法 编码算法是将一种形式转换成等价的另外一种形式.主要是为了方便某种特定场景的处理. 字母如何在计算机中表示呢? 用ASCII编码 那中文字符如何在计算机中表示呢? 用Unicode编码 如何同 ...
- /usr/bin/python与/usr/bin/env python的区别
Infi-chu: http://www.cnblogs.com/Infi-chu/ /usr/bin/env python执行时,先查找python解释器的路径,然后执行./usr/bin/pyth ...
- SOC中的DFT和BIST对比与比较-IC学习笔记(二)
ATE:ATE是Automatic Test Equipment的缩写,根据客户的测试要求.图纸及参考方案,采用MCU.PLC.PC基于VB.VC开发平台,利用TestStand&LabVIE ...
- 'express'不是内部或外部命令, 也不是可运行的程序, 或批处理文件
1. npm install -g express-generator 安装新的express框架2. express -h 错误提示: 'express'不是内部或外部命令, 也不是可运行的程序, ...
- 2017-2018-1 20155320《信息安全技术》实验二——Windows口令破解
2017-2018-1 20155320<信息安全技术>实验二--Windows口令破解 实验目的 了解Windows口令破解原理 对信息安全有直观感性认识 能够运用工具实现口令破解 实验 ...
- 20155336 《Java程序设计》实验二 (Java面向对象程序设计)实验报告
20155336 <Java程序设计>实验二 (Java面向对象程序设计)实验报告 实验内容 初步掌握单元测试和TDD 理解并掌握面向对象三要素:封装.继承.多态 初步掌握UML建模 熟悉 ...
- WPF 如何自定义一个弹框
------------吾亦无他,唯手熟尔,谦卑若愚,好学若饥------------- 简述: 手工以原生Grid的方式,自定义了一个仿弹窗效果,优点可以自定义,缺点需要自己实现以及维护整个弹窗的效 ...