ABS Ball

AtCoder
IDarc212_c
Time2000ms
Memory256MB
Difficulty
There are $N$ white balls. First, you paint each ball red or blue. Then, you place these $N$ red or blue painted balls in one of $M$ distinguishable boxes. Let $a_i$ and $b_i$ be the number of red and blue balls in the $i$\-th box, respectively. Find the sum, modulo $998244353$, of $\prod_{1\leq i \le M}|a_i-b_i|$ over all ways to place the balls. Here, two ways of placing balls are different if and only if at least one of $a_i$ and $b_i$ is different for some $i$. Particularly, **balls are not distinguished from each other**. ## Constraints * $1 \le N,M \le 10^7$ * All input values are integers. ## Input The input is given from Standard Input in the following format: $N$ $M$ [samples]
Samples
Input #1
2 1
Output #1
4

There are three ways to place balls in box $1$.  
If you place one red ball and one blue ball, $|a_1-b_1|=0$.  
If you place two red balls or two blue balls, $|a_1-b_1|=2$.  
Therefore, the answer is $0 + 2 + 2 = 4$.
Input #2
5 7
Output #2
0
Input #3
10000000 5000000
Output #3
965172629
API Response (JSON)
{
  "problem": {
    "name": "ABS Ball",
    "description": {
      "content": "There are $N$ white balls. First, you paint each ball red or blue. Then, you place these $N$ red or blue painted balls in one of $M$ distinguishable boxes. Let $a_i$ and $b_i$ be the number of red and",
      "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_c"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "There are $N$ white balls. First, you paint each ball red or blue.\nThen, you place these $N$ red or blue painted balls in one of $M$ distinguishable boxes.\nLet $a_i$ and $b_i$ be the number of red and...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments