HDU 5206 four inages strategy (space vector)

Source: Internet
Author: User

Chinese title: "Four Elephant Zhenfa"

Determine whether the space four points can form a square.

One AC, so excited ~

#include <algorithm> #include <iostream> #include <cstring> #include <cstdio> #include < Cmath>typedef Long Long ll;using namespace std;struct point{int x, Y, z;}; BOOL IsEqual (Point P1,point p2,point p3,point p4) {int A=pow (p2.x-p1.x, 2) +pow (p2.y-p1.y,2) +pow (p2.z-p1.z,2); int B=pow ( p4.x-p3.x, 2) +pow (p4.y-p3.y,2) +pow (p4.z-p3.z,2); return a==b;} BOOL Isvertical (Point P1,point p2,point p3,point p4) {p1.x=p2.x-p1.x;p1.y=p2.y-p1.y;p1.z=p2.z-p1.z;p3.x=p4.x-p3.x; P3.y=p4.y-p3.y;p3.z=p4.z-p3.z;int A=p1.x*p3.x+p1.y*p3.y+p1.z*p3.z;return a==0;} BOOL Istar (Point P1,point p2,point p3,point p4) {if (p2.x+p3.x-p1.x! = p4.x) return false;if (p2.y+p3.y-p1.y! = P4.y) return f Alse;if (p2.z+p3.z-p1.z! = p4.z) return False;return true;} int main () {point p[5];int t;scanf ('%d ', &t), for (int. cs=1;cs<=t;cs++) {printf ("Case #%d:", CS); for (int i=1;i<= 4;++i) {scanf ("%d", &p[i].x), scanf ("%d", &p[i].y), scanf ("%d", &p[i].z);} if (IsEqual (p[1],p[2],p[1],p[3)) && isvertical (p[1],p[2], P[1],p[3]) {if (Istar (p[1],p[2],p[3],p[4])) printf ("yes\n");} else if (isequal (p[1],p[2],p[1],p[4]) && isvertical (P[1],p[2],p[1],p[4])) {if (Istar (p[1],p[2],p[4],p[3])) printf ("yes\n");} else if (isequal (p[1],p[3],p[1],p[4]) && isvertical (P[1],p[3],p[1],p[4])) {if (Istar (p[1],p[3],p[4],p[2])) printf ("yes\n");} else{printf ("no\n");}} return 0;}

  

HDU 5206 four inages strategy (space vector)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.