E. 和的平方之和 / Sum of Square of Sum

    传统题 2000ms 256MiB

和的平方之和 / Sum of Square of Sum

该比赛已结束,您无法在比赛模式下递交该题目。您可以点击“在题库中打开”以普通模式查看和递交本题。

Statement

There are NN balls numbered 11 to NN. Ball ii has an integer AiA_i written on it.

For a way of choosing some balls from the NN balls, define the score of that choice as the square of the sum of the numbers written on the chosen balls.

Find the sum, modulo 998244353998244353, of the scores of all (NK)\binom{N}{K} ways of choosing KK balls from the NN balls.

Input

The input is given from Standard Input in the following format:

  • NN KK
  • A1A_1 A2A_2 \dots ANA_N

Output

Output the answer.

Constraints

  • 1KN2×1051 \leq K \leq N \leq 2\times 10^5
  • 1Ai1091 \leq A_i \leq 10^9
  • All input values are integers.
3 2
1 10 100
22422

There are three ways of choosing two balls from three balls: choosing balls 1,21,2 gives a score of (1+10)2=121(1+10)^2=121, choosing balls 1,31,3 gives a score of (1+100)2=10201(1+100)^2=10201, and choosing balls 2,32,3 gives a score of (10+100)2=12100(10+100)^2=12100.

The answer is the sum of these, 121+10201+12100=22422121+10201+12100=22422.

5 2
10 10 20 20 20
10600

Multiple balls may have the same number written on them.

2 1
998244353 998244353
0

Find the sum modulo 998244353998244353.

ABC471 赛后模拟赛 ✅

未参加
状态
已结束
规则
IOI
题目
7
开始于
2026-8-18 12:00
结束于
2026-8-25 12:00
持续时间
168 小时
主持人
参赛人数
65