Add Integer

AtCoder
IDarc212_f
Time2000ms
Memory256MB
Difficulty
You are given integers $N,M,X$. Perform the following series of operations to create a sequence $A$ of length $N$ consisting of non-negative integers. * Freely decide an integer sequence $A=(A_1,A_2)$ of length $2$. * Then, perform the following operation $N-2$ times on $A$. * Let $k=|A|$. Let $x=A_{k-1}, y=A_k$. Append either $x+y$ or $y-x$ to the end of $A$. A sequence $A$ is a good sequence if and only if it satisfies the following: * $0 \le A_i \le M \ (1 \le i \le N)$ * $A_N=X$ Find the sum, modulo $998244353$, of $A_1 \times A_2$ over all good sequences that can be obtained by the operations. ## Constraints * $3 \leq N \leq 2 \times 10^5$ * $1 \leq X \leq M \leq 2 \times 10^5$ * All input values are integers. ## Input The input is given from Standard Input in the following format: $N$ $M$ $X$ [samples]
Samples
Input #1
3 4 3
Output #1
8

Some possible sequences are $(0,3,3),(1,4,3),(2,1,3)$.
The sum of $A_1 \times A_2$ over all possible sequences is $8$.
Input #2
150000 160000 140000
Output #2
791841701
API Response (JSON)
{
  "problem": {
    "name": "Add Integer",
    "description": {
      "content": "You are given integers $N,M,X$. Perform the following series of operations to create a sequence $A$ of length $N$ consisting of non-negative integers. *   Freely decide an integer sequence $A=(A_1,A_",
      "description_type": "Markdown"
    },
    "platform": "AtCoder",
    "limit": {
      "time_limit": 2000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "arc212_f"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "You are given integers $N,M,X$.\nPerform the following series of operations to create a sequence $A$ of length $N$ consisting of non-negative integers.\n\n*   Freely decide an integer sequence $A=(A_1,A_...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments