Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- capacity = float(input())
- counter = 1
- while True:
- suitcase = input()
- if suitcase == "End":
- print("Congratulations! All suitcases are loaded!")
- break
- box = float(suitcase)
- if counter % 3 == 0:
- box *= 1.1
- if box > capacity:
- print("No more space!")
- break
- capacity -= box
- counter += 1
- print(f"Statistic: {counter - 1} suitcases loaded.")
- РЕШЕНИЕ С FOR:
- import sys
- capacity = float(input())
- for i in range(1, sys.maxsize):
- suitcase = input()
- if suitcase == "End":
- print("Congratulations! All suitcases are loaded!")
- print(f"Statistic: {i - 1} suitcases loaded.")
- break
- box = float(suitcase)
- if i % 3 == 0:
- box *= 1.1
- if box > capacity:
- print(f"No more space!\nStatistic: {i - 1} suitcases loaded.")
- break
- capacity -= box
- РЕШЕНИЕ С ТЕРНАРЕН ОПЕРАТОР ЛЕКО ТАРИКАТСКАТА:
- import sys
- capacity = float(input())
- for i in range(1, sys.maxsize):
- suitcase = input()
- if suitcase != "End":
- capacity -= float(suitcase) * (1.1 if i % 3 == 0 else 1)
- if capacity < 0 or suitcase == "End":
- print(f"No more space!" if capacity < 0 else "Congratulations! All suitcases are loaded!")
- print(f"Statistic: {i - 1} suitcases loaded.")
- break
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement