Coin

AtCoder
IDfps_24_g
Time2000ms
Memory256MB
Difficulty
You have an unlimited number of coins of denominations $1$, $2$, $\dots$, $M$ yen. Coins of the same denomination are indistinguishable. You are given integers $N$ and $L$. For each $m = 1, 2, \dots, M-L+1$, solve the following problem: * You may use coins of denominations $m, m+1, \dots, m+L-1$ freely. (Formally, you may use coins of denomination $x$ for all $x$ satisfying $m \leq x \leq m+L-1$.) Find the number of ways to pay exactly $N$ yen using these coins, modulo $998244353$. Two payment methods are considered different if there exists at least one denomination for which the number of coins used differs. ## Constraints * $1 \leq L \leq M \leq N \leq 5000$ * $N, M, L$ are integers ## Input The input is given from standard input in the following format: $N$ $M$ $L$ [samples]
Samples
Input #1
5 3 2
Output #1
3
1

For $m=1$, using coins of denominations $1$ and $2$, there are $3$ ways to pay exactly $5$ yen:

*   Pay $5$ coins of $1$ yen.
*   Pay $3$ coins of $1$ yen and $1$ coin of $2$ yen.
*   Pay $1$ coin of $1$ yen and $2$ coins of $2$ yen.

For $m=2$, using coins of denominations $2$ and $3$, there is $1$ way to pay exactly $5$ yen:

*   Pay $1$ coin of $2$ yen and $1$ coin of $3$ yen.
Input #2
5000 2500 2495
Output #2
878712345
520404421
886134625
125526485
307727973
257205353
API Response (JSON)
{
  "problem": {
    "name": "Coin",
    "description": {
      "content": "You have an unlimited number of coins of denominations $1$, $2$, $\\dots$, $M$ yen.   Coins of the same denomination are indistinguishable. You are given integers $N$ and $L$. For each $m = 1, 2, \\dots",
      "description_type": "Markdown"
    },
    "platform": "AtCoder",
    "limit": {
      "time_limit": 2000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "fps_24_g"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "You have an unlimited number of coins of denominations $1$, $2$, $\\dots$, $M$ yen.  \nCoins of the same denomination are indistinguishable.\nYou are given integers $N$ and $L$. For each $m = 1, 2, \\dots...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments