|
|
вернуться в форумОбщий форумHelp!What is wrong in my program on problem 1043? Послано wrong 14 янв 2002 16:30 I think my method to solve this problem is all right,but the result is just WA.Anyone please tell me what is wrong or give me some test cases,thanks a lot!And here is my program in C++: #include<iostream.h> #include<math.h> #define eps 1e-7 #define pi 2*asin(1) double a[3],b[3]; double x,y,r; double s0,s1,s2; double max(double m,double n) { if(m-n<eps)return n; return m; } double min(double m,double n) { if(n-m<eps)return n; return m; } void circle() { x=(a[0]*a[0]+b[0]*b[0]-a[1]*a[1]-b[1]*b[1])/2*(b[0]-b[2]); x-=(a[0]*a[0]+b[0]*b[0]-a[2]*a[2]-b[2]*b[2])/2*(b[0]-b[1]); x/=(a[0]-a[1])*(b[0]-b[2])-(a[0]-a[2])*(b[0]-b[1]); y=(a[0]-a[1])*(a[0]*a[0]+b[0]*b[0]-a[2]*a[2]-b[2]*b[2])/2; y-=(a[0]-a[2])*(a[0]*a[0]+b[0]*b[0]-a[1]*a[1]-b[1]*b[1])/2; y/=(a[0]-a[1])*(b[0]-b[2])-(a[0]-a[2])*(b[0]-b[1]); r=sqrt((x-a[0])*(x-a[0])+(y-b[0])*(y-b[0])); } double angle(double m,double n) { m-=x,n-=y; if(n>=0)return acos(m/r); n=-n; return 2*pi-acos(m/r); } int test(double s) { if(s-max(s0,s1)<eps&&s-min(s0,s1)>=eps)return 1; else return 0; } void main() { cin>>a[0]>>b[0]; cin>>a[1]>>b[1]; cin>>a[2]>>b[2]; circle(); s0=angle(a[0],b[0]); s1=angle(a[1],b[1]); s2=angle(a[2],b[2]); long mark=test(s2); double up,down,left,right; if(test(0)==mark){ right=x+r; } else right=max(a[0],a[1]); if(test(pi/2)==mark){ up=y+r; } else up=max(b[0],b[1]); if(test(pi)==mark){ left=x-r; } else left=min(a[0],a[1]); if(test(3*pi/2)==mark){ down=y-r; } else down=min(b[0],b[1]); mark=(long)ceil(up)-(long)floor(down); mark*=(long)ceil(right)-(long)floor(left); cout<<mark<<endl; } |
|
|