标签:
http://poj.org/problem?id=1266
Time Limit: 1000MS | Memory Limit: 10000K | |
Total Submissions: 823 | Accepted: 308 |
Description
Input
Output
Sample Input
476 612 487 615 478 616
Sample Output
66
Source
1 #include<iostream> 2 #include<algorithm> 3 #include<stdio.h> 4 #define max(a,b) a>b?a:b 5 #define min(a,b) a>b?b:a 6 #include<math.h> 7 using namespace std; 8 #define eps 1e-8 9 struct point{double x,y;}; 10 struct line {point a,b;}; 11 point a,b,c; 12 double xmult(point p1,point p2,point p0){ 13 return (p1.x-p0.x)*(p2.y-p0.y)-(p2.x-p0.x)*(p1.y-p0.y); 14 } 15 bool pp(point p) 16 { 17 double t1,t2; 18 t1=(xmult(a,c,b)); 19 t2=(xmult(a,p,b)); 20 if ((t1<0&&t2<0)||(t1>0&&t2>0)) return true; 21 return false; 22 } 23 double distan (point p1,point p2) 24 { 25 return sqrt((p1.x-p2.x)*(p1.x-p2.x)+(p1.y-p2.y)*(p1.y-p2.y)); 26 } 27 point inter(line u,line v) 28 { 29 point ret = u.a; 30 double t = ((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)); 31 ret.x +=(u.b.x-u.a.x)*t; 32 ret.y +=(u.b.y-u.a.y)*t; 33 return ret; 34 } 35 point circle(point a,point b,point c ) 36 { 37 line u,v; 38 u.a.x =(a.x+b.x)/2; 39 u.a.y = (a.y+b.y)/2; 40 u.b.x = u.a.x - a.y+b.y; 41 u.b.y = u.a.y + a.x-b.x; 42 v.a.x = (a.x+c.x)/2; 43 v.a.y = (a.y+c.y)/2; 44 v.b.x = v.a.x - a.y+c.y; 45 v.b.y = v.a.y+a.x-c.x; 46 return inter(u,v); 47 } 48 int main() 49 { 50 point d,e,p; 51 int cas =1; 52 while(~scanf("%lf %lf %lf %lf %lf %lf",&a.x,&a.y,&b.x,&b.y,&c.x,&c.y)) 53 { 54 d = circle(a,b,c); 55 double bj = distan(d,a); 56 double maxx,maxy,minx,miny; 57 double dd=d.x,yy=d.y; 58 int ax,bx,cx,ay,by,cy; 59 maxx=max(a.x,b.x); 60 maxx=max(maxx,c.x); 61 minx=min(a.x,b.x); 62 minx=min(minx,c.x); 63 maxy=max(a.y,b.y); 64 maxy=max(maxy,c.y); 65 miny=min(a.y,b.y); 66 miny=min(miny,c.y); 67 p.x=d.x-bj; 68 p.y=d.y; 69 if(pp(p)) 70 minx=p.x; 71 p.x=d.x+bj; 72 if(pp(p)) 73 maxx=p.x; 74 p.x=d.x; 75 p.y=d.y-bj; 76 if(pp(p)) 77 miny=p.y; 78 p.y=d.y+bj; 79 if(pp(p)) 80 maxy=p.y; 81 cx=(long)ceil(maxx-eps)-(long)floor(minx+eps); 82 cy=(long)ceil(maxy-eps)-(long)floor(miny+eps); 83 printf("%d\n",cx*cy); 84 } 85 return 0; 86 }
标签:
原文地址:http://www.cnblogs.com/jeff-wgc/p/4483824.html