Functional Square Root

AtCoder
IDfps_24_x
Time12000ms
Memory256MB
Difficulty
You are given a formal power series $F(x) = \sum_{i=0}^{N-1} f_i x^i$ over $\mathbb{F} _ {998244353}$, where $N \geq 2$ and $F(x) \bmod{x^2} = x$. It can be proven that there exists a unique formal power series $G(x) = \sum_{i=0}^{N-1} g_i x^i$ over $\mathbb{F} _ {998244353}$ such that: * $G(G(x)) \equiv F(x) \pmod{x^N}$, and * $G(x) \bmod{x^2} = x$. Your task is to find this $G(x)$. ## Constraints * $2 \leq N \leq 8000$ * $f_0 = 0$ * $f_1 = 1$ * $0 \leq f_i < 998244353$ for $2 \leq i \leq N-1$ * All input values are integers ## Input The input is given from standard input in the following format: $N$ $f_0$ $f_1$ $\dots$ $f_{N-1}$ [samples] ## Note This problem is a **hard challenge intended for those who have finished all other problems and still have time left**. The score is set relatively low compared to its difficulty. If you have not solved the other problems yet, it is recommended to do those first.
Samples
Input #1
3
0 1 4
Output #1
0 1 2

$G(x) = x + 2x^2$ satisfies the conditions.
Input #2
7
0 1 766294629 440423913 59187619 725560240 585990756
Output #2
0 1 882269491 824730961 772850352 694658399 134447547
API Response (JSON)
{
  "problem": {
    "name": "Functional Square Root",
    "description": {
      "content": "You are given a formal power series $F(x) = \\sum_{i=0}^{N-1} f_i x^i$ over $\\mathbb{F} _ {998244353}$, where $N \\geq 2$ and $F(x) \\bmod{x^2} = x$. It can be proven that there exists a unique formal po",
      "description_type": "Markdown"
    },
    "platform": "AtCoder",
    "limit": {
      "time_limit": 12000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "fps_24_x"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "You are given a formal power series $F(x) = \\sum_{i=0}^{N-1} f_i x^i$ over $\\mathbb{F} _ {998244353}$, where $N \\geq 2$ and $F(x) \\bmod{x^2} = x$.\nIt can be proven that there exists a unique formal po...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments