Ex - Sum of Prod of Min

AtCoder
IDabc279_h
Time2000ms
Memory256MB
Difficulty
You are given positive integers $N$ and $M$. Here, it is guaranteed that $N\leq M \leq 2N$. Print the sum, modulo $200\ 003$ (a prime), of the following value over all sequences of positive integers $S=(S_1,S_2,\dots,S_N)$ such that $\displaystyle \sum_{i=1}^{N} S_i = M$ (notice the unusual modulo): * $\displaystyle \prod_{k=1}^{N} \min(k,S_k)$. ## Constraints * $1 \leq N \leq 10^{12}$ * $N \leq M \leq 2N$ * All values in the input are integers. ## Input The input is given from Standard Input in the following format: $N$ $M$ [samples]
Samples
Input #1
3 5
Output #1
14

There are six sequences $S$ that satisfy the condition: $S=(1,1,3), S=(1,2,2), S=(1,3,1), S=(2,1,2), S=(2,2,1), S=(3,1,1)$.
The value $\displaystyle \prod_{k=1}^{N} \min(k,S_k)$ for each of those $S$ is as follows.

*   $S=(1,1,3)$ : $1\times 1 \times 3 = 3$
*   $S=(1,2,2)$ : $1\times 2 \times 2 = 4$
*   $S=(1,3,1)$ : $1\times 2 \times 1 = 2$
*   $S=(2,1,2)$ : $1\times 1 \times 2 = 2$
*   $S=(2,2,1)$ : $1\times 2 \times 1 = 2$
*   $S=(3,1,1)$ : $1\times 1 \times 1 = 1$

Thus, you should print their sum: $14$.
Input #2
1126 2022
Output #2
40166

Print the sum modulo $200\ 003$.
Input #3
1000000000000 1500000000000
Output #3
180030
API Response (JSON)
{
  "problem": {
    "name": "Ex - Sum of Prod of Min",
    "description": {
      "content": "You are given positive integers $N$ and $M$. Here, it is guaranteed that $N\\leq M \\leq 2N$. Print the sum, modulo $200\\ 003$ (a prime), of the following value over all sequences of positive integers $",
      "description_type": "Markdown"
    },
    "platform": "AtCoder",
    "limit": {
      "time_limit": 2000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "abc279_h"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "You are given positive integers $N$ and $M$. Here, it is guaranteed that $N\\leq M \\leq 2N$.\nPrint the sum, modulo $200\\ 003$ (a prime), of the following value over all sequences of positive integers $...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments