QOJ.ac

QOJ

Time Limit: 2 s Memory Limit: 512 MB Total points: 100 Hackable ✓

#6620. 线性分式变换

Statistics

线性分式变换是形如 $f(z) = \frac{az+b}{cz+d}$ ($a, b, c, d \in \mathbb{C}, ad - bc \neq 0$) 的函数,它将扩充复平面 $\mathbb{C} \cup \{\infty\}$ 映射到其自身。

给定 $f(z_1) = w_1$,$f(z_2) = w_2$ 以及 $f(z_3) = w_3$,其中 $z_1, z_2, z_3$ 是两两不同的复数,$w_1, w_2, w_3$ 也是两两不同的复数,你的任务是计算对于某个复数 $z_0$ 的 $f(z_0)$。可以证明,在给定约束条件下,答案总是唯一的。

输入格式

输入包含多个测试用例,第一行包含一个整数 $T$ ($1 \le T \le 10^5$),表示测试用例的数量。

为了明确输入格式,我们记 $z_0 = p_0+q_0i$,$z_1 = p_1+q_1i$,$z_2 = p_2+q_2i$,$z_3 = p_3+q_3i$,$w_1 = r_1+s_1i$,$w_2 = r_2 + s_2i$ 以及 $w_3 = r_3 + s_3i$,其中 $i$ 是虚数单位,满足 $i^2 = -1$。

对于每个测试用例,第一行包含四个整数 $p_1, q_1, r_1$ 和 $s_1$,第二行包含四个整数 $p_2, q_2, r_2$ 和 $s_2$,第三行包含四个整数 $p_3, q_3, r_3$ 和 $s_3$,第四行仅包含两个整数 $p_0$ 和 $q_0$。保证所有这些整数都在范围 $[-100, 100]$ 内,且答案 $f(z_0)$ 满足 $|f(z_0)| < 10^6$,其中 $|z| = |p + qi| = \sqrt{p^2 + q^2}$ ($p, q \in \mathbb{R}$) 是复数 $z$ 的模。

输出格式

对于每个测试用例,输出一行,包含两个实数 $c_0$ 和 $d_0$,分别表示 $f(z_0)$ 的实部和虚部。

如果实部和虚部的绝对误差或相对误差均不超过 $10^{-6}$,则你的答案被视为正确。形式化地说,假设你的输出为 $x$,裁判的答案为 $y$,则当且仅当 $\frac{|x-y|}{\max(1,|y|)} \le 10^{-6}$ 时,你的输出被接受。

样例

样例输入 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

1.000000000000000 0.000000000000000
0.000000000000000 1.000000000000000

说明

在第一个样例中,我们有 $f(z) = iz$,在第二个样例中,我们有 $f(z) = 1/z$。

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.