luogu#P5158. 【模板】多项式快速插值

    ID: 4136 远端评测题 3000ms 500MiB 尝试: 0 已通过: 0 难度: 9 上传者: 标签>数学O2优化快速傅里叶变换 FFT快速数论变换 NTT

【模板】多项式快速插值

Background

This is a template problem, with no background.

Problem Description

You are given nn points (xi,yi)(x_i, y_i).

Find a polynomial f(x)f(x) of degree n1n - 1 such that f(xi)yi(mod998244353)f(x_i)\equiv y_i\pmod{998244353}.

Input Format

The first line contains a positive integer nn.

The next nn lines each contain two integers xi,yix_i, y_i.

Output Format

Output one line: the coefficients of f(x)f(x) from low degree to high degree.

If the degree is less than n1n - 1, pad with 00 until there are nn coefficients.

4
1 1
2 4
3 9
4 16
0 0 1 0

Hint

Constraints:

1n1000001 \leqslant n \leqslant 100000.

0xi,yi<9982443530 \leqslant x_i, y_i \lt 998244353.

It is guaranteed that all xix_i are pairwise distinct.

For 30%30\% of the testdata, n5000n \leqslant 5000.

Note that the numbers you output must be integers in the range [0,998244353)[0, 998244353).

The testdata was generated using CYaRon within five minutes.

Translated by ChatGPT 5