#K82457. Calculate Final Prices After Sequential Discounts
Calculate Final Prices After Sequential Discounts
Calculate Final Prices After Sequential Discounts
You are given a list of original prices for several items and a corresponding list of discount sequences. For each item, you must apply the discounts in the given order. The final price for an item is calculated by applying each discount sequentially to the price. Specifically, if an item with initial price \(P\) is subjected to discounts \(d_1, d_2, \dots, d_k\) (given as percentages), then its final price \(P_f\) is given by:
[ P_f = P \times \prod_{i=1}^{k} \left(1 - \frac{d_i}{100}\right) ]
If an item does not have any discounts, its final price remains the same as the original price.
Input/Output Format: The program will read input from standard input and write the final prices (separated by spaces) to standard output. Each final price should be rounded to at most two decimal places and printed such that if the value is an integer or has a single decimal (like 90.0), it appears accordingly.
inputFormat
The first line contains a single integer \(N\) representing the number of items. The second line contains \(N\) space-separated numbers, each representing the original price of an item. This is followed by \(N\) lines. The \(i\)-th of these lines starts with an integer \(K_i\) (which can be 0), representing the number of discounts for the \(i\)-th item, followed by \(K_i\) space-separated integers representing the discount percentages to be applied in sequence.
outputFormat
Output a single line containing \(N\) space-separated numbers. Each number is the final price of the corresponding item after applying all discounts. The result for each item should be rounded to at most two decimal places. If the computed price is an integer or has one decimal place, output it accordingly (e.g., 90.0 instead of 90.00).
## sample1
100
1 10
90.0