AMPZZ Cross Spider Computational geometry

Source: Internet
Author: User

Original title Link: http://codeforces.com/gym/100523/attachments/download/2798/20142015- Ct-s02e07-codeforces-trainings-season-2-episode-7-en.pdf

Test instructions

Give you a bunch of three-dimensional points and ask if they're common

Exercises

Template problem, registration is good, need to pay attention to is common line

Code
#include <iostream>#include<cmath>#include<cstdio>#defineMax_n 100005using namespacestd;Const Doubleeps=1e-Ten; inlineDoubleSQRT (Doublea) {returnA <=0?0: sqrt (a);} InlineDoubleSQR (Doublea) {returnAA;}classPoint_3 { Public:    Doublex, y, Z; Point_3 () {} point_3 (DoubleXxDoubleYyDoubleZZ): X (xx), Y (yy), Z (ZZ) {} point_3operator-(Point_3 a) {returnPoint_3 (x-a.x, Y-A.Y, Z-a.z); }    DoubleLength ()Const {        returnSqrt (SQR (x) + SQR (y) +SQR (z)); }}; Point_3 Det (ConstPoint_3 &a,ConstPoint_3 &b) {returnPoint_3 (A.Y * b.z-a.z * b.y, A.Z * b.x-a.x * b.z, a.x * B.Y-A.Y *b.x);}DoubleDot (ConstPoint_3 &a,ConstPoint_3 &b) {returna.x * b.x + a.y * b.y + a.z *b.z;}DoubleVlen (Point_3 P) {returnp.length ();}intdot_inline (point_3 p1,point_3 p2,point_3 p3) {returnVlen (Det (P1-P2, P2-P3)) <EPS;}BOOLZeroDoublex) {returnFabs (x) <EPS;} Point_3 Pvec (point_3 s1,point_3 s2,point_3 S3) {returnDet (S1-S2), (S2-S3));}intDots_onplane (point_3 a,point_3 b,point_3 c,point_3 d) {returnZero (Dot (Pvec (A, B, c), D-a));}intN; Point_3 Point3[max_n];intMain () {scanf ("%d", &N);  for(inti =0; I < n; i++) {        intA, B, C; scanf ("%d%d%d", &a, &b, &c); Point3[i]=Point_3 (A, B, c); }    if(N <=3) {cout<<"TAK"<<Endl; return 0; }    intp =-1;  for(inti =2; I < n; i++) {        if(Dot_inline (point3[0], point3[1], point3[i]) = =0) {p=i;  Break; }    }    if(p = =-1) {cout<<"TAK"<<Endl; return 0; }     for(inti =2; I < n; i++) {        if(i = = p)Continue; if(Dots_onplane (point3[0], point3[1], point3[p], point3[i]) = =0) {cout<<"NIE"<<Endl; return 0; }} cout<<"TAK"<<Endl; return 0;}

AMPZZ Cross Spider Computational geometry

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.