#P7996. [WFOI - 01] 硬币(coin)
[WFOI - 01] 硬币(coin)
Problem Description
In front of you there is a row of piles of coins in a line. Coins in the same pile have the same face value; denote the face value of the -th pile by . The number of coins in each pile is the same, denoted by .
Now you are given the face value of each pile. You need to determine a positive integer such that the variance of the total amount of money in each pile is closest to a positive integer .
Definition of “closest” between two numbers: the absolute value of their difference is minimal.
Variance definition: $s ^ 2 = \cfrac{(a_1 - \bar x)^2 + (a_2 - \bar x) ^ 2 + \cdots + (a_n - \bar x) ^ 2}{n}$, where represents the average of .
Input Format
The first line contains two integers .
The second line contains integers. The -th integer is , meaning the face value of the -th pile is .
Output Format
Output one positive integer on one line, representing the value of that satisfies the requirement. If there are multiple answers, output the smallest one. If no matter what value takes the variance is always , output one line No answer!.
7 47
7 2 4 6 3 7 10
3
4 4
4 4 4 4
No answer!
Hint
[Sample Explanation]
When , the amount of money in the -th pile is . These amounts are . The variance of these amounts is approximately . It can be proven that when , the variance is closest to .
[Sample Explanation]
It can be found that no matter what value takes, the variance will be , so output No answer!.
[Constraints]
This problem uses bundled Subtask testdata.
| Subtask ID | |||
|---|---|---|---|
| Subtask #0 | |||
| Subtask #1 | |||
| Subtask #2 | |||
| Subtask #3 |
For of the testdata, , . Let the variance of the original array be . Then the testdata satisfies or .
[Hint]
The input size of this problem is large. Please use a suitable input method. Here we recommend a fast input template. For , you can also use scanf to read input.
To avoid precision issues, users are advised to use type , and it is not recommended to use eps.
Translated by ChatGPT 5