QOJ.ac

QOJ

実行時間制限: 1 s メモリ制限: 1024 MB 満点: 100

#3494. 对称多项式

統計

对称多项式是一个在变量的任何置换下保持不变的多项式。例如,$f(x_1, \dots, x_n) = x_1 + \dots + x_n$ 就是一个对称多项式(它实际上被称为第一初等对称多项式)。对称多项式有许多重要的应用。例如,它们可以用来证明一般五次多项式的根不存在通项公式。

然而,在本题中,我们将关注另一种对称性。考虑平面上的一条无限曲线 $P$,其 $x$ 和 $y$ 坐标均由多项式给出,即: $$x(t) = a_n t^n + a_{n-1} t^{n-1} + \dots + a_1 t + a_0$$ $$y(t) = b_m t^m + b_{m-1} t^{m-1} + \dots + b_1 t + b_0$$

如果存在一个实数 $t_0$,使得对于所有的 $t \in \mathbb{R}$,点 $(x(t_0 + t), y(t_0 + t))$ 关于直线 $L$(由方程 $Ax + By + C = 0$ 给出)的对称点为 $(x(t_0 - t), y(t_0 - t))$,则称该曲线关于直线 $L$ 对称,并将直线 $L$ 称为曲线 $P$ 的对称轴。例如,考虑由以下方程给出的曲线 $P$: $$x(t) = -5t^5 - 26t^4 - 19t^3 + 59t^2 + 111t + 26$$ $$y(t) = -t^5 + 17t^3 - 9t^2 - 61t + 12$$

该曲线关于直线 $5x + y + 92 = 0$ 对称,其中 $t_0 = -1$(见图 G.1)。

图 G.1:样例输入 1 的示意图,绘制范围为 $t = -3.9$ 到 $t = 1.9$。

现在,你的任务是编写一个程序,给定两个多项式 $x(t)$ 和 $y(t)$,找出该曲线的一条对称轴(如果存在的话)。

输入格式

输入的第一行包含一个整数 $n$ ($0 \le n \le 10$),表示 $x$ 的次数。接下来一行包含 $n+1$ 个整数 $a_n, \dots, a_1, a_0$,其中 $a_i$ 是 $x$ 的 $i$ 次项系数。随后两行以相同的格式描述多项式 $y$。

如果 $x(t)$ 或 $y(t)$ 为零多项式,其次数记为 0。系数的绝对值不超过 $1\,000$。你可以假设每个多项式的首项系数 $a_n$ 均不为零,除非该多项式本身就是零多项式。

输出格式

输出三个实数 $A, B$ 和 $C$,表示 $Ax + By + C = 0$ 是给定曲线的一条对称轴。如果不存在对称轴,则输出 $A = B = C = 0$。如果曲线有多条对称轴,输出其中任意一条即可。

在存在对称轴的情况下,所提供的直线必须满足以下条件: $0.5 \le \max(|A|, |B|) \le 10^{100}$。 所提供直线的方向与某条对称轴的方向偏差在 $10^{-6}$ 弧度以内。 * $\frac{C}{\max(|A|, |B|)}$ 的值在绝对误差或相对误差 $10^{-6}$ 以内是正确的。

样例

样例输入 1

5
-5 -26 -19 59 111 26
5
-1 0 17 -9 -61 12

样例输出 1

5 1 92

样例输入 2

1
1 0
3
1 0 0 0

样例输出 2

0 0 0

样例输入 3

1
1 0
0
0

样例输出 3

2.718281828 0 0

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.