QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 512 MB Total points: 100

#4871. 特殊方程

Statistics

设 $f(x) = a_n x^n + \dots + a_1 x + a_0$,其中 $a_i$ ($0 \le i \le n$) 均为已知整数。我们称 $f(x) \equiv 0 \pmod m$ 为同余方程。如果 $m$ 是合数,我们可以将 $m$ 分解为素数的幂,并求解每一个对应的方程,然后利用中国剩余定理将它们合并。在本题中,你需要求解此类方程的一个简化版本,其中 $m$ 为某个素数的平方。

输入格式

第一行包含方程的数量 $T$ ($T \le 50$)。 接下来 $T$ 行,每行以一个整数 $deg$ ($1 \le deg \le 4$) 开头,表示 $f(x)$ 的次数。随后是 $deg+1$ 个整数,依次表示 $a_n$ 到 $a_0$ ($0 < |a_n| \le 100$;当 $deg \ge 3$ 时,满足 $|a_i| \le 10000$;否则满足 $|a_i| \le 100000000, i < n$)。最后一个整数为素数 $pri$ ($pri \le 10000$)。 请注意,你的任务是求解 $f(x) \equiv 0 \pmod{pri \times pri}$。

输出格式

对于每个方程 $f(x) \equiv 0 \pmod{pri \times pri}$,首先输出样例编号,如果存在满足方程的 $x$,则输出其中任意一个,否则输出 "No solution!"。

样例

样例输入 1

4
2 1 1 -5 7
1 5 -2995 9929
2 1 -96255532 8930 9811
4 14 5458 7754 4946 -2210 9601

样例输出 1

Case #1: No solution!
Case #2: 599
Case #3: 96255626
Case #4: No solution!

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.