QOJ.ac

QOJ

実行時間制限: 2.0 s メモリ制限: 256 MB 満点: 100

#9106. Zayin 与 Dirichlet

統計

我们定义三种基本函数:

$$\mu(n) = \begin{cases} (-1)^\sigma & , n \text{ 无平方因子,且 } \sigma \text{ 为 } n \text{ 的质因子个数} \\ 0 & , \text{其他} \end{cases}$$ $$1(n) = 1$$ $$id_k(n) = n^k, k = 1, 2, 3, \dots$$

函数 $f$ 和 $g$ 的狄利克雷卷积(记作 $f * g$)是一个函数 $h$,满足:

$$h(n) = \sum_{d|n} f(d)g\left(\frac{n}{d}\right)$$

超过两个函数的狄利克雷卷积(例如有 $q$ 个函数 $f_1, f_2, \dots, f_q$)定义为:

$$f = (((f_1 * f_2) * f_3) * \dots) * f_q$$

Zayin 和 Ziyin 现在有许多基本函数(至少一个)。他们计算了所有这些函数的狄利克雷卷积,得到结果 $f$。Zayin 发现对于任意质数 $p$,$f(p^c)$ 是一个关于 $p$ 的 $n$ 次多项式,即 $f(p^c) = \sum_{i=0}^n a_i p^i$。但 $a_i$ 太大了,他只能告诉你 $a_i \pmod{998244353}$,即 $x_i$,其中 $0 \le x_i < 998244353$ 且 $x_i \equiv a_i \pmod{998244353}$。

Ziyin 发现对于任意质数 $p$,$f(p^d)$ 也是一个关于 $p$ 的多项式,但她不想告诉你它长什么样。你的任务是找出这个多项式。

如果有多个解,请输出最小的一个。多项式 $P(x) = \sum_{i=0}^n a_i x^i$ 小于 $Q(x) = \sum_{i=0}^m b_i x^i$ 当且仅当 $n < m$,或者 $n = m$ 且存在 $i \in [0, n]$,满足 $(\forall j \in [i+1, n], a_j = b_j) \land (a_i < b_i)$(模 998244353 后)。

如果无解,或者最小解所使用的基本函数个数超过 $10^5$,请输出 $-1$。

输入格式

第一行包含三个整数 $n, c$ 和 $d$ ($0 \le n \le 1000, 1 \le d \le c \le 100$)。 第二行包含 $n+1$ 个整数 $x_0, x_1, \dots, x_n$ ($0 \le x_i < 998244353, x_n \neq 0$)。

输出格式

如果满足上述条件,输出 $-1$。否则输出两行。 第一行包含一个整数 $m$,表示 Ziyin 的多项式的次数。 第二行包含 $m+1$ 个整数 $b_0, b_1, \dots, b_m$,表示 $f(p^d) = \sum_{i=0}^m b_i p^i$。当 $m > 0$ 时,必须确保 $b_m \neq 0$。由于答案可能非常大,请输出答案对 998244353 取模的结果。

样例

样例输入 1

2 2 1
1 1 1

样例输出 1

1
1 1

样例输入 2

2 2 1
998244352 998244352 1

样例输出 2

-1

说明

在第一个样例中,$f(p^2) = p^2 + p + 1$。$f(n)$ 可以看作 $n$ 的约数和,因此 $f(p) = p + 1$。 在第二个样例中,$f(p^2) = p^2 - p - 1$ 不能表示为基本函数的狄利克雷卷积。

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.