#C12352. Apply Discount to Products

    ID: 41770 Type: Default 1000ms 256MiB

Apply Discount to Products

Apply Discount to Products

You are given a list of products with their prices and a discount rate. Your task is to apply the discount to each product’s price and output the discounted prices rounded to two decimal places.

For each product, the new price is computed using the formula:

[ \text{new_price} = \text{price} \times (1 - \text{discount}) ]

The discounted price should be rounded to two decimal places. The order of the products in the output should be the same as the input.

Example:

Input:
0.10
3
apple 1.00
banana 0.50
orange 0.80

Output: apple 0.90 banana 0.45 orange 0.72

</p>

inputFormat

The input is read from standard input and has the following format:

  • The first line contains a floating-point number D representing the discount rate (e.g., 0.10 for 10%).
  • The second line contains an integer N representing the number of products.
  • Each of the next N lines contains a product name (a string without spaces) and its price (a floating-point number), separated by a space.

outputFormat

For each product, output a separate line containing the product name and its new discounted price separated by a space. The discounted price must be displayed with exactly two decimal places.

## sample
0.10
3
apple 1.00
banana 0.50
orange 0.80
apple 0.90

banana 0.45 orange 0.72

</p>