#K6801. List Normalization
List Normalization
List Normalization
Given a list of integers, normalize the list so that all values are scaled to lie within the range ([0,1]). The normalization is done using the formula:
[ normalized(x) = \frac{x - \min(\text{lst})}{\max(\text{lst}) - \min(\text{lst})} ]
If all elements are identical, return 0 for each element. If the list is empty, output nothing.
The input is provided via standard input, and the output should list the normalized values rounded to two decimal places and separated by spaces.
inputFormat
The first line contains an integer (n) representing the number of elements in the list. The second line contains (n) space-separated integers. If (n = 0), then the list is empty.
outputFormat
Output the normalized list of numbers rounded to two decimal places. The numbers should be separated by a single space.## sample
4
5 10 15 20
0.00 0.33 0.67 1.00