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 ...
随机推荐
- redis常用数据类型操作命令集锦
redis操作命令集锦 redis中五种数据类型 1) 字符串 String 特点: 存储所有的字符和字符串 应用场景: 做缓存使用 2) 哈希 hash 特点: 相当于java中hashMap集合 ...
- 使用CURL实现GET和POST方式请求
/** 使用curl方式实现get或post请求@param $url 请求的url地址@param $data 发送的post数据 如果为空则为get方式请求return 请求后获取到的数据 */f ...
- kubernetes命令式容器应用编排/部署应用/探查应用详情/部署service对象/扩缩容/修改删除对象
部署Pod应用 创建delpoyment控制器对象 [root@master ~]# kubectl run myapp --image=ikubernetes/myapp:v1 --port=80 ...
- FlexPaper 里的pdf2json.exe 下载地址
在使用FlexPaper 做在线阅读,需要使用到pdf2json.exe,将PDF转成JSON或者XML格式,网上很少下载的,现在提供一个下载的地址 http://pan.baidu.com/s/1i ...
- 20155222 2016-2017-2 《Java程序设计》第4周学习总结
20155222 2016-2017-2 <Java程序设计>第4周学习总结 教材学习内容总结 子类会继承父类的private成员,但是无法直接存取,必须通过父类提供的方法. 多态就是使用 ...
- 20155231 2016-2017-2《Java程序设计》课程总结
20155231 2016-2017-2<Java程序设计>课程总结 每周作业链接汇总 预备作业1:师生关系 预备作业2:优秀技能经验 预备作业3:虚拟机linux初接触 第一周作业:认识 ...
- linux Ubuntu Kali 安装flash
http://jingyan.baidu.com/article/fa4125accdeeec28ad709252.html
- 【LG5018】[NOIP2018pj]对称的二叉树
[LG5018][NOIP2018pj]对称的二叉树 题面 洛谷 题解 看到这一题全都是用\(O(nlogn)\)的算法过的 考场上写\(O(n)\)算法的我很不开心 然后就发了此篇题解... 首先我 ...
- 4825: [Hnoi2017]单旋
4825: [Hnoi2017]单旋 链接 分析: 以后采取更保险的方式写代码!!!81行本来以为不特判也可以,然后就总是比答案大1,甚至出现负数,调啊调啊调啊调~~~ 只会旋转最大值和最小值,以最小 ...
- js Date对象要注意的问题(时间转换)
1.时间戳和时间对象可以灵活转变: let n = new Date() // 返回的是当前时间对应的国际时间 let nt =n.getTime() let n2 =new Date(nt) con ...