AverageProblem
SRM 356 · 2007-07-02 · by Pawa
SRM 356 · 2007-07-02 · by Pawa · Brute Force, Simple Math, Simple Search, Iteration
Problem Statement
Problem Statement
You are given the results of a sociological survey containing several questions. Each participant was required to answer each question with an integer between 0 and 10, inclusive. You are given the average answer for each question, but the decimal portion of each average is truncated after the first three digits. For example, if there were three participants and their answers to a particular question were 4, 6 and 10, the average for that question would be given to you as 6.666.
You are given a
Constraints
- marks will contain between 1 and 50 elements, inclusive.
- Each element of marks will contain between 5 and 50 characters, inclusive.
- Each element of marks will be a single space separated list of numbers, where each number is between 0 and 10, inclusive, contains no extra leading zeroes, and contains exactly one decimal point followed by exactly 3 digits.
- marks will contain between 1 and 50 numbers, inclusive.
Examples
0)
{"0.000"}
Returns: 1
There will always be at least one participant. In this case, the smallest number of participants that could have produced this result is 1.
1)
{"0.500 0.250", "0.125"}
Returns: 8
2)
{"0.500","0.300"}
Returns: 10
3)
{"0.500","0.301"}
Returns: 106
4)
{"0.001", "0.002"}
Returns: 667
Submissions are judged against all 171 archived test cases, of which 5 are shown here. Case numbers match the judge’s.
Coding Area
Language: C++17 · define a public class AverageProblem with a public method int numberOfParticipants(vector<string> marks) · 171 test cases · 2 s / 256 MB per case