Snack

AtCoder
IDfps_24_a
Time2000ms
Memory256MB
Difficulty
For $D$ days, each day you choose exactly one of the following four actions: * Pay $1$ yen and buy gum. * Pay $3$ yen and buy candy. * Pay $4$ yen and buy chocolate. * Pay $6$ yen and buy wheat gluten snack. After $D$ days, you have paid a total of $N$ yen. How many possible sequences of $D$ days satisfy this condition? Output the answer modulo $998244353$. Two sequences are considered different if there exists at least one day on which the purchased item is different. ## Constraints * $1 \leq D \leq 2 \times 10^5$ * $1 \leq N \leq 10^6$ * $D, N$ are integers ## Input The input is given from standard input in the following format: $D$ $N$ [samples]
Samples
Input #1
2 7
Output #1
4

There are $4$ valid action sequences for $2$ days:

*   On day $1$, pay $1$ yen for gum; on day $2$, pay $6$ yen for wheat gluten snack.
*   On day $1$, pay $3$ yen for candy; on day $2$, pay $4$ yen for chocolate.
*   On day $1$, pay $4$ yen for chocolate; on day $2$, pay $3$ yen for candy.
*   On day $1$, pay $6$ yen for wheat gluten snack; on day $2$, pay $1$ yen for gum.
Input #2
200000 1000000
Output #2
688682037
API Response (JSON)
{
  "problem": {
    "name": "Snack",
    "description": {
      "content": "For $D$ days, each day you choose exactly one of the following four actions: *   Pay $1$ yen and buy gum. *   Pay $3$ yen and buy candy. *   Pay $4$ yen and buy chocolate. *   Pay $6$ yen and buy whe",
      "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_a"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "For $D$ days, each day you choose exactly one of the following four actions:\n\n*   Pay $1$ yen and buy gum.\n*   Pay $3$ yen and buy candy.\n*   Pay $4$ yen and buy chocolate.\n*   Pay $6$ yen and buy whe...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments