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 ",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 ",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 ",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 ",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 ",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 ",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 ",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 ",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 ",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 ",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 ",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 ",i); continue; } else { printf("Case #%d: No ",i); continue; } } }
版权声明:本文为博主原创文章,未经博主允许不得转载。