Sample Size
Time limit2sMemory limit512 MB
Given a set of rounded percentages, find the smallest number of interviewees N such that each percentage equals 100k/N rounded to the nearest integer.
- Level
Medium6 of 10
- Topics
- Math, Number theory, Binary search, Brute force
- Solved
- No attempts yet
Problem
While reading the results of a poll in a newspaper article, you might notice that all of the reported percentages are 25%, 50%, and 75% — which makes you suspect that perhaps only 4 people were interviewed, so the poll may not be very reliable.
In this problem you perform a similar analysis. Given the percentages that appear in a newspaper article, determine the minimum number of people that must have been interviewed so that all of those percentages are possible. Percentages are rounded to the nearest integer, with .5 rounded up. For example, 1 out of 3 people is 33%, 2 out of 3 people is 67%, and 155 out of 1000 people is 16%.
Formally, a percentage is achievable with interviewees if there is an integer with such that rounding gives that percentage. Output the smallest for which every percentage in the input is achievable.
Input
The first line contains an integer , the number of percentages that appear in the article. ()
Each of the following lines contains one integer percentage . ()
Output
Output the minimum number of people that must be interviewed so that every percentage in the input can be written as the rounded fraction of some number of those people.