SimeonTs

SUPyF2 D.Types and Vars Exercise - 10. Gladiator Expenses

Sep 27th, 2019
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.30 KB | None | 0 0
  1. """
  2. Data Types and Variables - Exercise
  3. Check your code: https://judge.softuni.bg/Contests/Practice/Index/1722#9
  4.  
  5. SUPyF2 D.Types and Vars Exercise - 10. Gladiator Expenses (not included in final score)
  6.  
  7. Problem:
  8. As a gladiator, Petar has to repair his broken equipment when he loses a fight.
  9. His equipment consists of helmet, sword, shield and armor. You will receive the Petar`s lost fights count.
  10. Every second lost game, his helmet is broken.
  11. Every third lost game, his sword is broken.
  12. When both his sword and helmet are broken in the same lost fight, his shield also brakes.
  13. Every second time, when his shield brakes, his armor also needs to be repaired.
  14. You will receive the price of each item in his equipment. Calculate his expenses for the year for renewing his equipment.
  15. Input / Constraints
  16. You will receive 5 parameters to your function:
  17. • First parameter – lost fights count – integer in the range [0, 1000].
  18. • Second parameter – helmet price - floating point number in range [0, 1000].
  19. • Third parameter – sword price - floating point number in range [0, 1000].
  20. • Fourth parameter – shield price - floating point number in range [0, 1000].
  21. • Fifth parameter – armor price - floating point number in range [0, 1000].
  22.  
  23. Output:
  24. • As output you must print Petar`s total expenses for new equipment: "Gladiator expenses: {expenses} aureus"
  25. • Allowed working time / memory: 100ms / 16MB.
  26.  
  27. Examples:
  28. Input:
  29. 7
  30. 2
  31. 3
  32. 4
  33. 5
  34. Output:
  35. Gladiator expenses: 16.00 aureus
  36. Comment:
  37. Trashed helmet -> 3 times
  38. Trashed sword -> 2 times
  39. Trashed shield -> 1 time
  40. Total: 6 + 6 + 4 = 16.00 aureus;
  41.  
  42. Input:
  43. 23
  44. 12.50
  45. 21.50
  46. 40
  47. 200
  48. Output:
  49. Gladiator expenses: 608.00 aureus
  50. """
  51. lost_fights_count = int(input())
  52. helmet_price = float(input())
  53. sword_price = float(input())
  54. shield_price = float(input())
  55. armor_price = float(input())
  56.  
  57. broken_shield_count = 0
  58.  
  59. total_price = 0
  60.  
  61. for fight in range(1, lost_fights_count + 1):
  62.     if fight % 2 == 0:
  63.         total_price += helmet_price
  64.     if fight % 3 == 0:
  65.         total_price += sword_price
  66.     if fight % 2 == 0 and fight % 3 == 0:
  67.         total_price += shield_price
  68.         broken_shield_count += 1
  69.         if broken_shield_count % 2 == 0:
  70.             total_price += armor_price
  71.  
  72. print(f"Gladiator expenses: {total_price:.2f} aureus")
Add Comment
Please, Sign In to add comment