列表

详情


NC230864. Linear Fractional Transformation

描述

The linear fractional transformations are the functions mapping the extended complex plane onto itself.

Given , and , where z_1, z_2 and z_3 are pairwise distinct complex numbers and w_1, w_2 and w_3 are also pairwise distinct complex numbers, your task is to calculate f(z_0) for a certain complex number z_0. It can be shown that the answer is always unique to the given contraints.

输入描述

The input contains several test cases, and the first line contains an integer T , indicating the number of test cases.

To clarify the input format, we denote , , , , , and , where i is the imaginary unit that .

Then for each test case, the first line contains four integers p_1, q_1, r_1 and s_1, the second contains four integers p_2, q_2, r_2 and s_2, the third line contains four integers p_3, q_3, r_3 and s_3, and the fourth line contains only two integers p_0 and q_0. It is guaranteed that all these integers are in the range and the answer f(z_0) satisfies , where is the modulus of the complex number z.

输出描述

For each test case, output a line containing two real numbers c_0 and d_0, indicating the real part and the imaginary part of f(z_0).

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 x and the jury's answer is y, 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 f(z)=iz, and in the second sample case we have f(z)=1/z.

原站题解

上次编辑到这里,代码来自缓存 点击恢复默认模板

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());
    }
    
}

上一题