#K52377. Vote Percentage Calculation
Vote Percentage Calculation
Vote Percentage Calculation
You are given the number of choices C and a list of votes for each choice. Your task is to calculate the percentage of the total votes that each choice received. If the total number of votes is zero, then each choice is considered to have 0.00% of the votes.
The percentage for each choice should be computed as follows:
( p_i = \frac{votes_i}{\sum_{j=1}^{C} votes_j} \times 100 )
and formatted as a string with exactly two decimals followed by a percent sign ("%").
Note: The input is provided via stdin
and the output should be printed to stdout
.
inputFormat
The first line of input contains an integer C which denotes the number of choices. The second line contains C space-separated integers representing the number of votes for each choice.
outputFormat
Output exactly C lines, where each line contains the percentage of votes for the corresponding choice formatted as a string with two decimal places followed by a percent sign. If the total votes is zero, print "0.00%" for each choice.
## sample3
50 25 25
50.00%
25.00%
25.00%
</p>