Four Inages Strateg
Four Inages Strategy
Young F found a secret record which inherited from ancient times in ancestral home by accident, which named "Four Inages Strategy". He couldn't restrain inner exciting, open the record, and read it carefully. " Place four magic stones at four points as array element in space, if four magic stones form a square, then strategy activates, destroying enemy around". Young F traveled to all corners of the country, and have collected four magic stones finally. He placed four magic stones at four points, but didn't know whether strategy could active successfully. So, could you help him?
Multiple test cases, the first line contains an integer
For each case, the output should occupies exactly one line. The output format is Case #
2 0 0 0 0 1 0 1 0 0 1 1 0 1 1 1 2 2 2 3 3 3 4 4 4
Case #1: Yes Case #2: No
#include<iostream> #include<cstdlib> #include<cstdio> using namespace std; int x1,y1,z1; int x2,y2,z2; int x3,y3,z3; int x4,y4,z4; int T; int main() { scanf("%d",&T); for(int i=1;i<=T;i++) { scanf("%d%d%d%d%d%d%d%d%d%d%d%d",&x1,&y1,&z1,&x2,&y2,&z2,&x3,&y3,&z3,&x4,&y4,&z4); if((x2-x1)*(x3-x1)+(y2-y1)*(y3-y1)+(z2-z1)*(z3-z1)==0&&((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1)+(z2-z1)*(z2-z1)==(x3-x1)*(x3-x1)+(y3-y1)*(y3-y1)+(z3-z1)*(z3-z1))&&(x4==x3+x2-x1&&y4==y3+y2-y1&&z4==z3+z2-z1)) { printf("Case #%d: Yes\n",i); continue; } else if((x2-x1)*(x4-x1)+(y2-y1)*(y4-y1)+(z2-z1)*(z4-z1)==0&&((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1)+(z2-z1)*(z2-z1)==(x4-x1)*(x4-x1)+(y4-y1)*(y4-y1)+(z4-z1)*(z4-z1))&&(x3==x4+x2-x1&&y3==y4+y2-y1&&z3==z4+z2-z1)) { printf("Case #%d: Yes\n",i); continue; } else if((x3-x1)*(x4-x1)+(y3-y1)*(y4-y1)+(z3-z1)*(z4-z1)==0&&((x3-x1)*(x3-x1)+(y3-y1)*(y3-y1)+(z3-z1)*(z3-z1)==(x4-x1)*(x4-x1)+(y4-y1)*(y4-y1)+(z4-z1)*(z4-z1))&&(x2==x4+x3-x1&&y2==y4+y3-y1&&z2==z4+z3-z1)) { printf("Case #%d: Yes\n",i); continue; } else if((x1-x2)*(x3-x2)+(y1-y2)*(y3-y2)+(z1-z2)*(z3-z1)==0&&((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)+(z1-z2)*(z1-z2)==(x3-x2)*(x3-x2)+(y3-y2)*(y3-y2)+(z3-z2)*(z3-z2))&&(x4==x3+x1-x2&&y4==y3+y1-y2&&z4==z3+z1-z2)) { printf("Case #%d: Yes\n",i); continue; } else if((x1-x2)*(x4-x2)+(y1-y2)*(y4-y2)+(z1-z2)*(z4-z1)==0&&((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)+(z1-z2)*(z1-z2)==(x4-x2)*(x4-x2)+(y4-y2)*(y4-y2)+(z4-z2)*(z4-z2))&&(x3==x4+x1-x2&&y3==y4+y1-y2&&z3==z4+z1-z2)) { printf("Case #%d: Yes\n",i); continue; } else if((x3-x2)*(x4-x2)+(y3-y2)*(y4-y2)+(z3-z2)*(z4-z1)==0&&((x3-x2)*(x3-x2)+(y3-y2)*(y3-y2)+(z3-z2)*(z3-z2)==(x4-x2)*(x4-x2)+(y4-y2)*(y4-y2)+(z4-z2)*(z4-z2))&&(x1==x4+x3-x2&&y1==y4+y3-y2&&z1==z4+z3-z2)) { printf("Case #%d: Yes\n",i); continue; } else if((x1-x3)*(x2-x3)+(y1-y3)*(y2-y3)+(z1-z3)*(z2-z3)==0&&((x1-x3)*(x1-x3)+(y1-y3)*(y1-y3)+(z1-z3)*(z1-z3)==(x2-x3)*(x2-x3)+(y2-y3)*(y2-y3)+(z2-z3)*(z2-z3))&&(x4==x2+x1-x3&&y4==y2+y1-y3&&z4==z2+z1-z3)) { printf("Case #%d: Yes\n",i); continue; } else if((x1-x3)*(x4-x3)+(y1-y3)*(y4-y3)+(z1-z3)*(z4-z3)==0&&((x1-x3)*(x1-x3)+(y1-y3)*(y1-y3)+(z1-z3)*(z1-z3)==(x4-x3)*(x4-x3)+(y4-y3)*(y4-y3)+(z4-z3)*(z4-z3))&&(x2==x4+x1-x3&&y2==y4+y1-y3&&z2==z4+z1-z3)) { printf("Case #%d: Yes\n",i); continue; } else if((x2-x3)*(x4-x3)+(y2-y3)*(y4-y3)+(z2-z3)*(z4-z3)==0&&((x2-x3)*(x2-x3)+(y2-y3)*(y2-y3)+(z2-z3)*(z2-z3)==(x4-x3)*(x4-x3)+(y4-y3)*(y4-y3)+(z4-z3)*(z4-z3))&&(x1==x4+x2-x3&&y1==y4+y2-y3&&z1==z4+z2-z3)) { printf("Case #%d: Yes\n",i); continue; } else if((x1-x4)*(x2-x4)+(y1-y4)*(y2-y4)+(z1-z4)*(z2-z4)==0&&((x1-x4)*(x1-x4)+(y1-y4)*(y1-y4)+(z1-z4)*(z1-z4)==(x2-x4)*(x2-x4)+(y2-y4)*(y2-y4)+(z2-z4)*(z2-z4))&&(x3==x2+x1-x4&&y3==y2+y1-y4&&z3==z2+z1-z4)) { printf("Case #%d: Yes\n",i); continue; } else if((x1-x4)*(x3-x4)+(y1-y4)*(y3-y4)+(z1-z4)*(z3-z4)==0&&((x1-x4)*(x1-x4)+(y1-y4)*(y1-y4)+(z1-z4)*(z1-z4)==(x3-x4)*(x3-x4)+(y3-y4)*(y3-y4)+(z3-z4)*(z3-z4))&&(x2==x4+x1-x4&&y2==y4+y1-y4&&z2==z4+z1-z4)) { printf("Case #%d: Yes\n",i); continue; } else if((x2-x4)*(x3-x4)+(y2-y4)*(y3-y4)+(z2-z4)*(z3-z4)==0&&((x2-x4)*(x2-x4)+(y2-y4)*(y2-y4)+(z2-z4)*(z2-z4)==(x3-x4)*(x3-x4)+(y3-y4)*(y3-y4)+(z3-z4)*(z3-z4))&&(x1==x3+x2-x4&&y1==y3+y2-y4&&z1==z3+z2-z4)) { printf("Case #%d: Yes\n",i); continue; } else { printf("Case #%d: No\n",i); continue; } } }
版权声明:本文为博主原创文章,未经博主允许不得转载。
posted on 2015-04-18 21:09 Tob__yuhong 阅读(141) 评论(0) 编辑 收藏 举报
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步