Original Address http://www.cnblogs.com/Christopher-Cao/p/5482575.html
This problem is a bare question of computational geometry. It seems to be folded a few times to use something to maintain, in fact, because n<=8 so can be violent statistics. The only difficult thing is to find the point of the symmetry point (in fact, there is no difficulty it)
Paste Code
1#include <cstdio>2#include <cmath>3#include <vector>4 using namespacestd;5 6 Const intMAXN =Ten ; 7 Const intMAXM = - ; 8 Const DoubleEPS = 1e-6 ; 9 intN, M;Ten One structPoint { A Doublex, y; -Point (Const DoubleXConst Doubley): - x (x), Y (y) {}; the } ; - - structVector { - Doublex, y; +Vector (Const DoubleXConst Doubley): - x (x), Y (y) {}; + } ; A at structLine { - Point from , to; -Line (Const DoubleX1,Const DoubleY1, - Const DoubleX2,Const Doubley2): - From (x1, y1), to (x2, y2) {}; -Vector Tovector ()Const ; in } ; - toVectoroperator- (ConstPoint & First,ConstPoint &Second) { + returnVector (First X-second x, first Y-Second. Y); - } the *Pointoperator- (ConstPoint & First,ConstVector &Second) { $ returnPoint (First X-second x, first Y-Second. Y); Panax Notoginseng } - theVectoroperator* (Const DoubleKConstVector &Input) { + returnVector (k * Input. x, K *Input. Y); A } the +Pointoperator+ (ConstPoint & First,ConstVector &Second) { - returnPoint (First x + Second. x, first y +Second. Y); $ } $ - //above is the definition of vectors and various addition and subtraction operations - Double operator^ (ConstVector & First,ConstVector &Second) { the returnFirst. X * Second. Y-first. Y *Second. x; - } Wuyi //Cross Product the Double operator* (ConstVector & First,ConstVector &Second) { - returnFirst. X * Second. x + first. Y *Second. Y; Wu } - //Inner Product About DoubleABS (ConstVector &Input) { $ returnsqrt (input. x * input. x + input. Y *Input. Y); - } - //die -Vector Line:: Tovector ()Const{returnTo-from ;} A +Vector < line >Opts; the -Point Reflect (ConstPoint O,ConstLine L) { $ Const DoubleDis = ((L). From-o) ^ (L. To-o))/ABS (L. Tovector ()); the ConstVector Lp =1.0/abs (L. tovector ()) *L. Tovector (); the returnO +2.0* Dis * Vector (Lp. Y,-Lp. x); the } the - intQuery (ConstPoint O,Const intT) { in //printf ("Dfs%.2lf%.2lf%d\n",o.x,o.y,t); the if(T = =-1 ) the return(EPS <= o. x && o. x <=100.0-EPS) && About(eps <= o. y && o. Y <=100.0-EPS); the //This place did not add EPS at first, so WA (conscience example) the Const DoubleCrossvalue = the(Opts [T]. From-o) ^ (Opts [T]. To-o)); + if(Crossvalue <-EPS)return 0 ; - if(-EPS <= crossvalue && crossvalue <= EPS)return 0 ; the //This place is more a row because at the beginning of the reading of the problem when the boundary is counted only once, and then did not have a sample to understand the boundary does not countBayi returnQuery (O, T-1) + theQuery (Reflect (o, Opts [t]), T-1 ) ; the } - - intMain () { thescanf ("%d", &N); the for(inti =0; i < N; ++i) { the Doublex1, y1, x2, y2; thescanf ("%LF%LF%LF%LF", & X1, & Y1, & x2, &y2); - Opts. Push_back (Line (x1, y1, x2, y2)); the } thescanf ("%d", &M); the while(M-- ) {94 Doublex, y; thescanf ("%LF%LF", & X, &y); theprintf ("%d\n", Query (Point (x, y), N-1 ) ) ; the }98 return 0 ; About}
BZOJ1074 [SCOI2007] Origami Origami