Score

AtCoder
IDfps_24_i
Time2000ms
Memory256MB
Difficulty
You are given $N$ distinct integers $A_1, A_2, \dots, A_N$. You will choose $K$ of them. The **score** of a choice is defined as the product of the chosen integers. There are $\binom{N}{K}$ possible ways to choose $K$ integers. Find the sum of their scores, and output the result modulo $998244353$. ## Constraints * $1 \leq N \leq 2 \times 10^5$ * $1 \leq K \leq N$ * $1 \leq A_i \leq 10^8$ * If $i \neq j$, then $A_i \neq A_j$ * All input values are integers ## Input The input is given from standard input in the following format: $N$ $K$ $A_1$ $A_2$ $\dots$ $A_N$ [samples]
Samples
Input #1
3 2
2 3 5
Output #1
31

The possible ways to choose $K$ integers and their scores are:

*   Choose $A_1 = 2$ and $A_2 = 3$. The score is $2 \times 3 = 6$.
*   Choose $A_1 = 2$ and $A_3 = 5$. The score is $2 \times 5 = 10$.
*   Choose $A_2 = 3$ and $A_3 = 5$. The score is $3 \times 5 = 15$.
Input #2
10 5
1 2 3 4 5 6 7 8 9 10
Output #2
902055
API Response (JSON)
{
  "problem": {
    "name": "Score",
    "description": {
      "content": "You are given $N$ distinct integers $A_1, A_2, \\dots, A_N$.   You will choose $K$ of them. The **score** of a choice is defined as the product of the chosen integers.   There are $\\binom{N}{K}$ possib",
      "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_i"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "You are given $N$ distinct integers $A_1, A_2, \\dots, A_N$.  \nYou will choose $K$ of them. The **score** of a choice is defined as the product of the chosen integers.  \nThere are $\\binom{N}{K}$ possib...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments