Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/python3
- import sys
- # Complete the function below.
- # Sarah has 'n' dollar
- # Cupcake flat cost or 'c'
- # 1 free cupcake for every m cupcake wrappers
- def maximumCupcakes(trips):
- for entry in trips:
- split_entry = entry.split(" ")
- print(split_entry)
- print(type(split_entry))
- n = int(split_entry[0]) # 6
- c = int(split_entry[1]) # 2
- m = int(split_entry[2]) # 2
- cupcakes_with_wrappers = 0
- wrappers = 0
- cupcakes_with_money = int(n / c) # initial wrappers # 6 / 2 = 3
- wrappers = cupcakes_with_money # 3
- while(wrappers >= m): # accounting for multiple trips to the
- cupcakes_with_wrappers = cupcakes_with_wrappers + int(wrappers / m) # wrappers we get with our initial wrappers
- wrappers = int(wrappers / m) + (wrappers % m) # wrappers after buying with wrappers
- print(cupcakes_with_money + cupcakes_with_wrappers)
- if __name__ == "__main__":
- trips_cnt = 0
- trips_cnt = int(input())
- trips_i = 0
- trips = []
- while trips_i < trips_cnt:
- try:
- trips_item = str(input())
- except:
- trips_item = None
- trips.append(trips_item)
- trips_i += 1
- res = maximumCupcakes(trips);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement