NC230864. Linear Fractional Transformation
描述
输入描述
The input contains several test cases, and the first line contains an integer , indicating the number of test cases.
To clarify the input format, we denote , , , , , and , where is the imaginary unit that .
Then for each test case, the first line contains four integers , , and , the second contains four integers , , and , the third line contains four integers , , and , and the fourth line contains only two integers and . It is guaranteed that all these integers are in the range and the answer satisfies , where is the modulus of the complex number .
输出描述
For each test case, output a line containing two real numbers and , indicating the real part and the imaginary part of .
Your answer is acceptable if the absolute or relative errors of both the real part and the imaginary part do not exceed . Formally speaking, suppose that your output is and the jury's answer is , your output is accepted if and only if .
示例1
输入:
2 -1 0 0 -1 0 1 -1 0 1 0 0 1 0 -1 -1 0 -1 0 0 1 0 -1 1 0 1 0 0 -1
输出:
1.000000000000000 0.000000000000000 0.000000000000000 1.000000000000000
说明:
In the first sample case we have , and in the second sample case we have .C++ 解法, 执行用时: 528ms, 内存消耗: 8320K, 提交时间: 2021-11-23 19:47:43
#include<bits/stdc++.h> using namespace std; typedef complex<double> C; C getC(){ int x,y;cin>>x>>y; return C(x,y); } int T; int main(){ int t;scanf("%d",&t); while(t--){ C z_0=getC(),w_0=getC(),z_1=getC(),w_1=getC(),z_2=getC(),w_2=getC(),z_3=getC(); C t=(z_0-z_3)/(z_1-z_3)/((z_0-z_2)/(z_1-z_2))*((w_0-w_2)/(w_1-w_2))-C(1,0); C w_3=w_1-(w_0-w_1)/t; printf("%.12f %.12f\n",w_3.real(),w_3.imag()); } }