Advertisement
SimeonTs

SUPyF2 P.-Mid-Exam/18 December 2018 - 01. Christmas Spirit

Oct 30th, 2019
583
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.78 KB | None | 0 0
  1. """
  2. Technology Fundamentals Retake Mid Exam - 18 December 2018
  3. Check your code: https://judge.softuni.bg/Contests/Practice/Index/1395#0
  4.  
  5. SUPyF2 P.-Mid-Exam/18 December 2018 - 01. Christmas Spirit
  6.  
  7. Problem:
  8. It's time to get in a Christmas mood.
  9. You have to decorate the house in time for the big event, but you have limited days to do so.
  10. You will receive allowed quantity for one type of decoration and days left until Christmas day to decorate the house.
  11. There are 4 types of decorations and each piece costs a price
  12. • Ornament Set – 2$ a piece
  13. • Tree Skirt – 5$ a piece
  14. • Tree Garlands – 3$ a piece
  15. • Tree Lights – 15$ a piece
  16. Every second day you buy an Ornament Set quantity of times and increase your Christmas spirit by 5.
  17. Every third day you buy Tree Skirts and Tree Garlands (both quantity of times) and increase your spirit by 13.
  18. Every fifth day you buy Tree Lights quantity of times and increase your Christmas spirit by 17.
  19. If you have bought Tree Skirts and Tree Garlands at the same day you additionally increase your spirit by 30.
  20. Every tenth day you lose 20 spirit,
  21. because your cat ruins all tree decorations and you have to rebuild the tree and buy one piece of tree skirt,
  22. garlands and lights.
  23. That is why you are forced to increase the allowed quantity with 2 at the beginning of every eleventh day.
  24. Also if the last day is a tenth day the cat decides to demolish even more and ruins the Christmas turkey
  25. and you lose additional 30 spirit.
  26. At the end you must print the total cost and the gained spirit.
  27. Input / Constraints
  28. The input will consist of exactly 2 lines:
  29. • quantity – integer in range [1…100]
  30. • days – integer in range [1…100]
  31. Output
  32. At the end print the total cost and the total gained spirit in the following format:
  33. • "Total cost: {budget}"
  34. • "Total spirit: {totalSpirit}"
  35.  
  36. Examples:
  37.  
  38. Input:      Output:
  39. 1           Total cost: 37
  40. 7           Total spirit: 58
  41.  
  42. Input:      Output:
  43. 3           Total cost: 558
  44. 20          Total spirit: 156
  45. """
  46. quantity = int(input())
  47. days = int(input())
  48.  
  49. ornament_set = 2
  50. tree_skirt = 5
  51. tree_garlands = 3
  52. tree_lights = 15
  53.  
  54. total = 0
  55. spirit = 0
  56.  
  57. for day in range(1, days + 1):
  58.     if day % 11 == 0:
  59.         quantity += 2
  60.  
  61.     if day % 2 == 0:
  62.         total += ornament_set * quantity
  63.         spirit += 5
  64.  
  65.     if day % 3 == 0:
  66.         total += (tree_skirt * quantity) + (tree_garlands * quantity)
  67.         spirit += 13
  68.  
  69.     if day % 5 == 0:
  70.         total += tree_lights * quantity
  71.         spirit += 17
  72.         if day % 3 == 0:
  73.             spirit += 30
  74.  
  75.     if day % 10 == 0:
  76.         spirit -= 20
  77.         total += tree_skirt + tree_garlands + tree_lights
  78.         if day == days:
  79.             spirit -= 30
  80.  
  81. print(f"Total cost: {total}")
  82. print(f"Total spirit: {spirit}")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement