Blue Bridge Cup Python Group - Shopping List

Blue Bridge Cup Python Group - Shopping List

Topic description

This question is a fill-in-the-blank question. After calculating the result, use the output statement in the code to output the filled result.

Xiao Ming has just found a job, and the boss is very nice, but his wife loves shopping. When the boss is busy, he often asks Xiao Ming to go to the mall to do shopping on his behalf. Xiao Ming was very tired, but he couldn't refuse.

Nope, the big promotion is here again! The boss's wife opened a long shopping list, all with discounts.

Xiao Ming also has a quirk. Unless it is a last resort, he never swipes his card and gets it directly in cash.

Xiao Ming is very upset now. Please help him calculate how much cash he needs to withdraw from the ATM to complete this shopping.

ATMs can only provide 100-yuan banknotes. Xiao Ming wants to withdraw as little cash as possible, as long as it is enough. Your task is to calculate the minimum amount of cash that Xiao Ming needs to withdraw.

Here's a vexing shopping list, with item names hidden for privacy.

****     180.90       88****      10.25       65****      56.14        9****     104.65        9****     100.30       88****     297.15        半价
****      26.75       65****     130.62        半价
****     240.28       58****     270.62        8****     115.87       88****     247.34       95****      73.21        9****     101.00        半价
****      79.54        半价
****     278.44        7****     199.26        半价
****      12.97        9****     166.30       78****     125.50       58****      84.98        9****     113.35       68****     166.57        半价
****      42.56        9****      81.90       95****     131.78        8****     255.89       78****     109.17        9****     146.69       68****     139.33       65****     141.16       78****     154.74        8****      59.42        8****      85.44       68****     293.70       88****     261.79       65****      11.30       88****     268.27       58****     128.29       88****     251.03        8****     208.39       75****     128.88       75****      62.06        9****     225.87       75****      12.89       75****      34.28       75****      62.16       58****     129.12        半价
****     218.37        半价
****     289.69        8

It should be noted that the 12% discount refers to 88% of the list price, while the 82% discount is calculated at 80%, and the rest are analogous. In particular, half price is calculated at 50%.

Please output the amount that Xiao Ming wants to withdraw from the ATM, in yuan.

Running limit
Maximum running time: 1s
Maximum running memory: 128M

import math
data = '''
****     180.90       88折
****      10.25       65折
****      56.14        9折
****     104.65        9折
****     100.30       88折
****     297.15        半价
****      26.75       65折
****     130.62        半价
****     240.28       58折
****     270.62        8折
****     115.87       88折
****     247.34       95折
****      73.21        9折
****     101.00        半价
****      79.54        半价
****     278.44        7折
****     199.26        半价
****      12.97        9折
****     166.30       78折
****     125.50       58折
****      84.98        9折
****     113.35       68折
****     166.57        半价
****      42.56        9折
****      81.90       95折
****     131.78        8折
****     255.89       78折
****     109.17        9折
****     146.69       68折
****     139.33       65折
****     141.16       78折
****     154.74        8折
****      59.42        8折
****      85.44       68折
****     293.70       88折
****     261.79       65折
****      11.30       88折
****     268.27       58折
****     128.29       88折
****     251.03        8折
****     208.39       75折
****     128.88       75折
****      62.06        9折
****     225.87       75折
****      12.89       75折
****      34.28       75折
****      62.16       58折
****     129.12        半价
****     218.37        半价
****     289.69        8折
'''
data = data.split()
sum = 0
for i in range(0,len(data),3):
    price = float(data[i+1])
    discount = data[i+2]
    if len(discount) == 2:
        if discount == "半价":
            discount = 0.5
        else:
            discount = float(discount[:-1])*0.1
    else:
        discount = float(discount[:-1])*0.01
    sum += price*discount
print(math.ceil(sum/100)*100)

insert image description here

Thank you for your support. Your one-click three-connection is the biggest driving force for Ganggang students!

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324322232&siteId=291194637