#P17251. 均值
均值
Background
An easy problem, no background.
Problem Description
For a multiset , define one operation on as follows:
- Let be the average of all elements in , i.e. , where is the sum of all elements in , and is the number of elements in (duplicate elements are counted multiple times).
- Let , i.e. the minimum value of the absolute difference between an element in and .
- Choose an element from such that . If multiple elements satisfy this, choose any one of them.
- Then delete one from , and insert one into .
For example, performing one operation on can yield or . Note that a multiset is unordered.
Given positive integers and a multiset , compute how many different multisets may be obtained after performing operations on . Output the result modulo .
Input Format
The first line contains two positive integers , separated by spaces.
The second line contains positive integers , separated by spaces.
Output Format
Output one non-negative integer in one line, denoting the number of different multisets that may be obtained modulo .
6 1
2 4 1 4 6 1
2
2 3
1 9
8
Hint
Sample 1 Explanation
The following multisets may be obtained: .
Note that is the same as .
Constraints
It is guaranteed that .
This problem uses bundled testdata.
Special conditions for subtasks are as follows:
| Subtask | Score | |||
|---|---|---|---|---|
| 0 | ||||
| 1 | ^ | ^ | ||
| 2 | ||||
| 3 | ^ | ^ | ||
| 4 | ||||
| 5 | ^ | ^ |
Translated by ChatGPT 5