http://poj.org/problem?id=1266
Cover an ARC.
Time Limit: 1000MS |
|
Memory Limit: 10000K |
Total Submissions: 823 |
|
Accepted: 308 |
Description
A Huge Dancing-hall is constructed for the Ural state University ' s 80-th Anniversary celebration. The size of the hall is metres! The floor is made of square mirror plates with side equal to 1 metre. Then the walls were painted with an indelible paint. Unfortunately, in the end of the painter flapped the brush and the beautiful mirror floor were stained with the paint. But isn't everything is lost yet! The stains can covered with a carpet.
Nobody knows why, but the paint on the floor formed a arc of a circle (a centre of the circle lies inside the hall). The dean of the Department of mathematics and mechanics measured the coordinates of the arc ' s ends and of some other point The of the arc (he is sure, the this information was quite enough for any student of the Ural state University). The Dean wants to cover the arc with a rectangular carpet. The sides of a carpet must go along the sides of the mirror plates (so, the corners of the carpet must has an integer coordi Nates).
You should find the minimal square of such a carpet.
Input
The input consists of six integers. At first the coordinates of the arc ' s ends is given. The co-ordinates of a inner point of the arc follow them. Absolute value of coordinates doesn ' t exceed 1000. The points don ' t belong the same straight line. The arc lies inside the square [ -1000,1000] * [ -1000,1000].
Output
You should write to the standard output the minimal square of the carpet covering this arc.
Sample Input
476 612487 615478 616
Sample Output
66
Source
Ural State University Internal Contest October ' Students Session (Ural 1043) Analysis: Geometry problem, the area of the square cover arc. AC Code:
1#include <iostream>2#include <algorithm>3#include <stdio.h>4 #defineMax (A, b) a>b?a:b5 #defineMin (A, b) a>b?b:a6#include <math.h>7 using namespacestd;8 #defineEPS 1e-89 structpoint{Doublex, y;};Ten structLine {point a b;}; One Point a,b,c; A DoubleXmult (Point p1,point p2,point p0) { - return(p1.x-p0.x) * (P2.Y-P0.Y)-(p2.x-p0.x) * (p1.y-p0.y); - } the BOOLpp (point P) - { - Doublet1,t2; -t1=(Xmult (a,c,b)); +T2=(Xmult (a,p,b)); - if((t1<0&&t2<0)|| (t1>0&&t2>0))return true; + return false; A } at DoubleDistan (Point p1,point p2) - { - returnsqrt ((p1.x-p2.x) * (p1.x-p2.x) + (P1.Y-P2.Y) * (p1.y-p2.y)); - } - Point Inter (line U,line v) - { inPoint ret =u.a; - DoubleT = ((u.a.x-v.a.x) * (V.A.Y-V.B.Y)-(U.A.Y-V.A.Y) * (v.a.x-v.b.x))/((u.a.x-u.b.x) * (V.A.Y-V.B.Y)-(U.A.Y-U.B.Y) * (v.a.x-v.b.x)); toRet.x + = (u.b.x-u.a.x) *T; +Ret.y + = (U.B.Y-U.A.Y) *T; - returnret; the } * Point Circle (Point a,point b,point c) $ {Panax Notoginseng Line u,v; -u.a.x = (a.x+b.x)/2; theU.A.Y = (A.Y+B.Y)/2; +u.b.x = u.a.x-a.y+b.y; AU.B.Y = u.a.y + a.x-b.x; thev.a.x = (a.x+c.x)/2; +V.A.Y = (A.Y+C.Y)/2; -v.b.x = v.a.x-a.y+c.y; $V.B.Y = v.a.y+a.x-c.x; $ returnInter (u,v); - } - intMain () the { - Point d,e,p;Wuyi intCAS =1; the while(~SCANF ("%lf%lf%lf%lf%lf%lf",&a.x,&a.y,&b.x,&b.y,&c.x,&c.y)) - { WuD =Circle (a,b,c); - DoubleBJ =Distan (d,a); About DoubleMaxx,maxy,minx,miny; $ Doubledd=d.x,yy=D.y; - intAx,bx,cx,ay,by,cy; -maxx=Max (a.x,b.x); -maxx=Max (maxx,c.x); Aminx=min (a.x,b.x); +minx=min (minx,c.x); themaxy=Max (A.Y,B.Y); -maxy=Max (MAXY,C.Y); $miny=min (a.y,b.y); theminy=min (miny,c.y); thep.x=d.x-BJ; thep.y=D.y; the if(PP (p)) -minx=p.x; inp.x=d.x+BJ; the if(PP (p)) themaxx=p.x; Aboutp.x=d.x; thep.y=d.y-BJ; the if(PP (p)) theminy=p.y; +p.y=d.y+BJ; - if(PP (p)) themaxy=p.y;BayiCx= (Long) Ceil (maxx-eps)-(Long) Floor (minx+EPS); theCy= (Long) Ceil (maxy-eps)-(Long) Floor (miny+EPS); theprintf"%d\n", cx*cy); - } - return 0; the}
POJ 1266 Cover an ARC.