#C8400. Packet Size Percentage Calculator
Packet Size Percentage Calculator
Packet Size Percentage Calculator
This problem involves calculating the percentage representation of each packet size relative to the total data size. Given a list of packet sizes and the total size, you are required to compute the percentage that each packet contributes. Each percentage should be rounded to two decimal places. The calculation is performed using the formula: $$\text{percentage}_i = \frac{\text{packet\_size}_i}{\text{total\_size}} \times 100$$
inputFormat
The input is given in three lines:
- The first line contains an integer
n
, representing the number of packets. - The second line contains
n
space-separated integers representing the sizes of the packets in bytes. - The third line contains an integer representing the total size of all packets in bytes.
outputFormat
Output a single line containing n
space-separated floating point numbers. Each number represents the percentage that the corresponding packet size contributes to the total size, rounded to two decimal places.
3
500 1500 1000
3000
16.67 50.00 33.33