The MacPRONALTS is with a super promotion, exclusive to the contestants of the first Selective MaratonaTEC. But they had a problem, all runners were trying to buy at the same time, so this generated a very long queue. The worst is that the cashier girl no have calculator or a program to help her to calculate more quickly. You are the person that will help the girl and the MacPRONALTS increase their sells. Bellow has a menu day, that contains the product number and its value.
The first entry is reported the number of purchased products (1 <= p <= 5). For each product follows the quantity (1 <= q <= 500) that the customer purchased.
Obs .: the product number will not be repeated.
Output
You must print the purchase amount with two decimal places.
1001 | R$ 1.50
1002 | R$ 2.50
1003 | R$ 3.50
1004 | R$ 4.50
1005 | R$ 5.50
InputThe first entry is reported the number of purchased products (1 <= p <= 5). For each product follows the quantity (1 <= q <= 500) that the customer purchased.
Obs .: the product number will not be repeated.
Output
You must print the purchase amount with two decimal places.
Input Sample | Output Sample |
2 1001 2 1005 3 | 19.50 |
1 1003 500 | 1750.00 |
5 1001 500 1005 300 1003 23 1002 52 1004 44 | 2808.50 |
Solution Using Python:
Dic = {'1001' : 1.50,'1002' : 2.50,'1003' : 3.50,'1004' : 4.50,'1005' : 5.50}
T = int(input())
S = 0
while T>0:
P, O = map(int,input().split())
P = str(P)
S = S + (O*Dic[P])
T-=1
print("%.2f"%S)
Comments
Post a Comment