#P17251. 均值

    ID: 19694 远端评测题 1000ms 256MiB 尝试: 0 已通过: 0 显示难度普及+/提高− 上传者: 标签>数学O2优化分类讨论

均值

Background

An easy problem, no background.

Problem Description

For a multiset SS, define one operation on SS as follows:

  • Let avg\rm avg be the average of all elements in SS, i.e. ∑S∣S∣\frac{\sum S}{|S|}, where ∑S\sum S is the sum of all elements in SS, and ∣S∣|S| is the number of elements in SS (duplicate elements are counted multiple times).
  • Let m=min⁡x∈S∣x−avg∣m=\min\limits_{x \in S}|x-\mathrm{avg}|, i.e. the minimum value of the absolute difference between an element in SS and avg\rm avg.
  • Choose an element xx from SS such that ∣x−avg∣=m|x-\mathrm{avg}|=m. If multiple elements satisfy this, choose any one of them.
  • Then delete one xx from SS, and insert one avg\rm avg into SS.

For example, performing one operation on {2,4,1,4,6,1}\{2,4,1,4,6,1\} can yield {3,4,1,4,6,1}\{3,4,1,4,6,1\} or {2,4,1,3,6,1}\{2,4,1,3,6,1\}. Note that a multiset is unordered.

Given positive integers n,kn,k and a multiset A={a1,a2,⋯ ,an}A=\{a_1,a_2,\cdots,a_n\}, compute how many different multisets may be obtained after performing kk operations on AA. Output the result modulo 998244353998244353.

Input Format

The first line contains two positive integers n,kn,k, separated by spaces.
The second line contains nn positive integers a1,a2,⋯ ,ana_1,a_2,\cdots,a_n, separated by spaces.

Output Format

Output one non-negative integer in one line, denoting the number of different multisets that may be obtained modulo 998244353998244353.

6 1
2 4 1 4 6 1 
2
2 3
1 9 
8

Hint

Sample 1 Explanation

The following multisets may be obtained: {3,4,1,4,6,1},{2,4,1,3,6,1}\{3,4,1,4,6,1\},\{2,4,1,3,6,1\}.

Note that {2,3,1,4,6,1}\{2,3,1,4,6,1\} is the same as {2,4,1,3,6,1}\{2,4,1,3,6,1\}.

Constraints

It is guaranteed that 1≤n≤5×105,1≤ai,k≤1091 \le n \le 5 \times 10^5,1 \le a_i,k \le 10^9.

This problem uses bundled testdata.

Special conditions for subtasks are as follows:

Subtask nn kk aia_i Score
0 ≤5\le 5 =1=1 ≤10\le 10 1010
1 ^ ≤109\le 10^9 ^ 1515
2 ≤5000\le 5000 =1=1 ≤105\le 10^5 1010
3 ^ ≤109\le 10^9 ^ 1515
4 ≤5×105\le 5 \times 10^5 =1=1 ≤109\le 10^9 2020
5 ^ ≤109\le 10^9 ^ 3030

Translated by ChatGPT 5