luogu#P5245. 【模板】多项式快速幂

【模板】多项式快速幂

Background

Enhanced version link

This is a template problem, with no background.

Problem Description

Given a polynomial A(x)A(x) of degree n1n-1, find a polynomial B(x)B(x) modulo xnx^n such that B(x)(A(x))k (mod xn)B(x) \equiv (A(x))^k \ (\bmod\ x^n).

The coefficients of the polynomials are computed modulo 998244353998244353.

Input Format

The first line contains two integers n,kn, k.

The next line contains nn integers, representing the coefficients of A(x)A(x) in order: a0,a1,...,an1a_0, a_1, ..., a_{n-1}.

Output Format

Output nn integers, representing the first nn coefficients of B(x)B(x) in order: b0,b1,...,bn1b_0, b_1, ..., b_{n-1}. Each coefficient should be the smallest non-negative integer modulo 998244353998244353.

9 18948465
1 2 3 4 5 6 7 8 9
1 37896930 597086012 720637306 161940419 360472177 560327751 446560856 524295016
4 1
1 1 0 0

1 1 0 0
4 2
1 1 0 0

1 2 1 0

4 3
1 1 0 0
1 3 3 1

Hint

For 100%100\% of the testdata, 1<n1051 < n \leq 10^5, 0<k101050 < k \leq 10^{10^5}, ai[0,998244352]a_i \in [0,998244352], and a0=1a_0 = 1.

Translated by ChatGPT 5