题目链接: tzc3056
方法:计算几何
注意:本题在输出结果的时候要将数据强制转换成整型,不能用%.0lf输出,否则会WA。
代码:
#include <iostream>
#include <cmath>
using namespace std;
const double eps=1e-10;
struct point{ double x,y; };
struct line{ double a,b,c; };
point point_about_line(point A,line L)
{
line L1;
point res;
if(fabs(L.a)<eps)
{
res.x=A.x;
res.y=-L.c/L.b*2-A.y;
return res;
}
if(fabs(L.b)<eps)
{
res.y=A.y;
res.x=-L.c/L.a*2-A.x;
return res;
}
L1.a=L.b;L1.b=-L.a;
L1.c=-L1.a*A.x-L1.b*A.y;
L.c=L.a*A.x+L.b*A.y+2*L.c;
L1.c=L1.a*A.x+L1.b*A.y+2*L1.c;
res.y=(L.a*L1.c-L1.a*L.c)/(L1.a*L.b-L.a*L1.b);
res.x=(-L.b*res.y-L.c)/L.a;
return res;
}
//点关于直线的对称点
point mirror(point P,line L)
{
point Q;
double A,B,C;
A=L.a;B=L.b;C=L.c;
Q.x=((B*B-A*A)*P.x-2*A*B*P.y-2*A*C)/(A*A+B*B);
Q.y=((A*A-B*B)*P.y-2*A*B*P.x-2*B*C)/(A*A+B*B);
return Q;
}
int main()
{
point A,B;
line L;
int t;
cin>>t;
while(t--)
{
cin>>A.x>>A.y;
cin>>L.a>>L.b>>L.c;
//B=point_about_line(A,L);
B=mirror(A,L);
printf("%d %d\n",(int)B.x,(int)B.y);
}
return 0;
}