Distance Sequence

AtCoder
IDabc253_e
Time2000ms
Memory256MB
Difficulty
How many integer sequences $A=(A_1,\ldots,A_N)$ of length $N$ satisfy all the conditions below? * $1\le A_i \le M$ $(1 \le i \le N)$ * $|A_i - A_{i+1}| \geq K$ $(1 \le i \le N - 1)$ Since the count can be enormous, find it modulo $998244353$. ## Constraints * $2 \leq N \leq 1000$ * $1 \leq M \leq 5000$ * $0 \leq K \leq M-1$ * All values in input are integers. ## Input Input is given from Standard Input in the following format: $N$ $M$ $K$ [samples]
Samples
Input #1
2 3 1
Output #1
6

The following $6$ sequences satisfy the conditions.

*   $(1,2)$
*   $(1,3)$
*   $(2,1)$
*   $(2,3)$
*   $(3,1)$
*   $(3,2)$
Input #2
3 3 2
Output #2
2

The following $2$ sequences satisfy the conditions.

*   $(1,3,1)$
*   $(3,1,3)$
Input #3
100 1000 500
Output #3
657064711

Print the count modulo $998244353$.
API Response (JSON)
{
  "problem": {
    "name": "Distance Sequence",
    "description": {
      "content": "How many integer sequences $A=(A_1,\\ldots,A_N)$ of length $N$ satisfy all the conditions below? *   $1\\le A_i \\le M$ $(1 \\le i \\le N)$      *   $|A_i - A_{i+1}| \\geq K$ $(1 \\le i \\le N - 1)$      Si",
      "description_type": "Markdown"
    },
    "platform": "AtCoder",
    "limit": {
      "time_limit": 2000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "abc253_e"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "How many integer sequences $A=(A_1,\\ldots,A_N)$ of length $N$ satisfy all the conditions below?\n\n*   $1\\le A_i \\le M$ $(1 \\le i \\le N)$\n    \n*   $|A_i - A_{i+1}| \\geq K$ $(1 \\le i \\le N - 1)$\n    \n\nSi...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments