USACO bronze
Bessie the cow was excited to recently return to in-person learning! Unfortunately, her instructor, Farmer John, is a very
boring lecturer, and so she ends up falling asleep in class often.
Copyright By PowCoder代写 加微信 powcoder
Farmer John has noticed that Bessie has not been paying attention in class. He has asked another student in class, Elsie, to
keep track of the number of times Bessie falls asleep in a given class. There are N class periods (1 < N < 105), and Elsie
logs that Bessie fell asleep at times (0 < a; < 100) in the i-th class period. The total number of times Bessie fell asleep across
all class periods is at most 10°
Elsie, feeling very competitive with Bessie, wants to make Farmer John feel like Bessie is consistently falling asleep the
same number of times in every class - making it appear that the issue is entirely Bessie's fault, with no dependence on
Farmer John's sometimes-boring lectures. The only way Elsie may modify the log is by combining two adjacent class
periods. For example, if a = 1, 2, 3, 4, 5), then if Elsie combines the second and third class periods the log will become
Help Elsie compute the minimum number of modifications to the log that she needs to make so that she can make all the
numbers in the log equal
INPUT FORMAT (input arrives from the terminal / stdin):
Each input will contain I (1 < T < 10) test cases that should be solved independently.
The first line contains T, the number of test cases to be solved. The T test cases follow, each described by a pair of lines.
The first line of each pair contains V, and the second contains a1, a2, ..., aN.
It is guaranteed that within each test case, the sum of all values in a is at most 100 It is also quaranteed that the sum of N
over all test cases is at most 105
OUTPUT FORMAT (print output to the terminal / stdout):
Please write I lines of output, giving the minimum number of modifications Elsie could perform to make all the log entries
equal for each case
SAMPLE INPUT:
SAMPLE OUTPUT:
For the first test case in this example, Elsie can change her log to consist solely of 35 with 3 modifications.
For the second test case, Elsie can change her log to 7 with 2 modifications.
程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com