HDU 2671 Can't be easier
简单的几何题目
点(a,b)关于直线Ax+By+C=1对称点的公式
#include<cstdio> #include<cstring> #include<cmath> #include<algorithm> using namespace std; double k; double X1,Y1,X2,Y2,X3,Y3,X4,Y4; int T; double a,b,c; int main() { scanf("%d",&T); while(T--) { scanf("%lf",&k); scanf("%lf%lf%lf%lf%lf%lf",&X1,&Y1,&X2,&Y2,&X3,&Y3); a=k,b=-1,c=Y3-k*X3; X4=X1-2*a*(a*X1+b*Y1+c)/(a*a+b*b); Y4=Y1-2*b*(a*X1+b*Y1+c)/(a*a+b*b); printf("%.2lf\n",max(sqrt((X2-X1)*(X2-X1)+(Y2-Y1)*(Y2-Y1)), sqrt((X2-X4)*(X2-X4)+(Y2-Y4)*(Y2-Y4)))); } return 0; }