TopCoder problem "AverageProblem" used in SRM 356 (Division I Level One , Division II Level Two)



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 String[] marks. Each element of marks is a single space delimited list of numbers. Each number in marks is the average answer for a survey question. Return the minimum possible number of participants that could have taken this survey.
 

Definition

    
Class:AverageProblem
Method:numberOfParticipants
Parameters:String[]
Returns:int
Method signature:int numberOfParticipants(String[] marks)
(be sure your method is public)
    
 

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

Problem url:

http://www.topcoder.com/stat?c=problem_statement&pm=7901

Problem stats url:

http://www.topcoder.com/tc?module=ProblemDetail&rd=10765&pm=7901

Writer:

Pawa

Testers:

PabloGilberto , brett1479 , Olexiy , ivan_metelsky

Problem categories:

Brute Force, Simple Math, Simple Search, Iteration