P5248 [LnOI2019SP] Fast Polynomial Transform (FPT).

Background

![avartar](https://cdn.luogu.com.cn/upload/pic/52800.png)

Description

This is a constructive problem. Shino thinks of a polynomial $f(x)$ with $n+1$ terms. The degree of the $i$-th term is $i$, and its coefficient is $a_i$: $$f(x)=a_0+a_1x+a_2x^2+a_3x^3+ \cdots +a_nx^n$$ Given $m$ and the value of $f(m)$ (that is, the value of this polynomial when $x=m$), please construct a polynomial such that for any $0 \leq a_i < m$, $a_i$ is a non-negative integer. Let the number of terms of the polynomial you construct be $n$. Then it must satisfy $1 \le n \le 100$, and the leading coefficient must be non-zero.

Input Format

Two integers, $m$ and $f(m)$.

Output Format

The first line outputs a positive integer $n$, which represents the number of terms of the polynomial. The second line outputs $n$ non-negative integers ($a_0$ to $a_{n-1}$) in order, with **exactly one** space between each pair of adjacent integers.

Explanation/Hint

For $20\%$ of the testdata, $2 \le m \le 5$. For $100\%$ of the testdata, $2 \le m,f(m) \le 10^{18}$. For all testdata, the time limit is $1000\text{ms}$ and the memory limit is $256\text{MB}$. You may enable O2 optimization. Translated by ChatGPT 5