/* [NKP'05] GIANT COVER by Jan Kuipers */ using namespace std; #include #include #include #include double eps = 1e-9; class point { public: double x,y,z; point() { x=y=z=0; } point(double _x, double _y, double _z) { x=_x; y=_y; z=_z; } }; point operator - (point a, point b) { return point(a.x-b.x, a.y-b.y, a.z-b.z); } point operator ^ (point a, point b) { return point(a.y*b.z-a.z*b.y, a.z*b.x-a.x*b.z, a.x*b.y-a.y*b.x); } double operator * (point a, point b) { return a.x*b.x + a.y*b.y + a.z*b.z; } bool operator == (point a, point b) { return a.x==b.x && a.y==b.y && a.z==b.z; } double len (point a) { return sqrt(1.0*(a*a)); } int main () { int runs; scanf ("%i\n",&runs); while (runs--) { vector p; int x1,y1,x2,y2; scanf ("%i %i %i %i\n",&x1,&y1,&x2,&y2); p.push_back(point(x1,y1,0)); p.push_back(point(x2,y1,0)); p.push_back(point(x2,y2,0)); p.push_back(point(x1,y2,0)); int N; scanf ("%i\n",&N); for (int i=0; i > done(N, vector(N, -1)); queue q; q.push(0); q.push(1); done[1][0]=2; done[0][3]=9999; done[3][2]=9999; done[2][1]=9999; double area=0.0; while (!q.empty()) { int A = q.front(); q.pop(); int B = q.front(); q.pop(); if (done[A][B]!=-1) continue; point n = (p[done[B][A]]-p[B]) ^ (p[done[B][A]]-p[A]); int C = -1; double Ccos3D = -1e100; double Ccos2D = -1e100; double Cdist = -1e100; for (int i=0; iCcos3D+eps) || (icos3D>Ccos3D-eps && icos2D>Ccos2D+eps) || (icos3D>Ccos3D-eps && icos2D>Ccos2D-eps && Cdist