题意:求布洛卡点坐标
思路:直接利用布洛卡点的性质。http://pan.baidu.com/s/1eQiP76E
1 #include<cstdio> 2 #include<cstring> 3 #include<algorithm> 4 #include<iostream> 5 #include<cstdlib> 6 #include<cstring> 7 #include<cmath> 8 #include<vector> 9 #define clc(a,b) memset(a,b,sizeof(a)) 10 using namespace std; 11 const double eps=1e-8; 12 const double pi=acos(-1); 13 const int maxn=1000010; 14 using namespace std; 15 16 int t; 17 int main() 18 { 19 while(~scanf("%d",&t)) 20 { 21 while(t--) 22 { 23 int K; 24 double c,d,a,b,e,f,m1,m2,m3,k,q; 25 double x,y; 26 scanf("%d%lf%lf%lf%lf%lf%lf",&K,&a,&b,&e,&f,&c,&d); 27 double l1,l2,l3; 28 l1=(a-e)*(a-e)+(b-f)*(b-f); 29 l2=(c-e)*(c-e)+(d-f)*(d-f); 30 l3=(c-a)*(c-a)+(d-b)*(d-b); 31 m1=(l1*l3*l3)/(l1*l2+l2*l3+l3*l1); 32 m2=(l3*l2*l2)/(l1*l2+l2*l3+l3*l1); 33 m3=(l2*l1*l1)/(l1*l2+l2*l3+l3*l1); 34 if(a!=c&&b!=d) 35 { 36 k=(-a+e)/(-a+c); 37 q=(-b+f)/(-b+d); 38 x=(e*e-b*b+(1-q)*m1-m3+q*m2+q*(b*b-c*c)+f*f-a*a+q*(a*a-d*d))/(2*q*a-2*q*c-2*a+2*e); 39 y=(e*e-b*b+m1*(1-k)-m3+k*m2+k*(b*b-c*c)-a*a+f*f+k*(a*a-d*d))/(2*k*b-2*k*d-2*b+2*f); 40 printf("%d %.5f %.5f ",K,x,y); 41 } 42 else if(a==c) 43 { 44 y=(m1-m2+d*d-b*b)/(-2*b+2*d); 45 x=a+sqrt(m1-(y-b)*(y-b)); 46 printf("%d %.5f %.5f ",K,x,y); 47 } 48 else 49 { 50 x=(m1-m2+c*c-a*a)/(-2*a+2*c); 51 y=b+sqrt(m1-(x-a)*(x-a)); 52 printf("%d %.5f %.5f ",K,x,y); 53 } 54 } 55 } 56 return 0; 57 }