Advertisement
SimeonTs

SUPyF2 P.-Mid-Exam/10 March 2019/2 - 01. The Hunting Games

Oct 29th, 2019
245
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 4.53 KB | None | 0 0
  1. """
  2. Technology Fundamentals Mid Exam - 10 March 2019 Group 2
  3. Check your code: https://judge.softuni.bg/Contests/Practice/Index/1555#0
  4.  
  5. SUPyF2 P.-Mid-Exam/10 March 2019/2 - 01. The Hunting Games
  6.  
  7. Problem:
  8. A group of friends have decided to participate in a game called "The Hunting Games".
  9. The first stage of the game is to gather some supplies.
  10. They have a list and your job is to help them follow it and make the needed calculations.
  11. Write a program that calculates the needed provisions for a quest in the woods.
  12. First you will receive the days of the adventure, the count of the players and the group’s energy.
  13. Afterwards, you will receive the following provisions per day for one person:
  14.  Water
  15.  Food
  16. The group calculates how many supplies they’d need for the adventure and take that much water and food.
  17. Every day they chop wood and lose a certain amount of energy.
  18. For each of the days, you are going to receive the energy loss from chopping wood.
  19. The program should end If the energy reaches 0 or less.
  20. Every second day they drink water,
  21. which boosts their energy with 5% of their current energy and at the same time drops
  22. their water supplies by 30% of their current water.
  23. Every third day they eat, which reduces their food supplies by the following amount:
  24. {currentFood} / {countOfPeople} and at the same time raises their group’s energy by 10%.
  25. The chopping of wood, the drinking of water, and the eating happen in the order above.
  26. If they have enough energy to finish the quest, print the following message:
  27. "You are ready for the quest. You will be left with - {energyLevel} energy!"
  28. If they run out of energy print the following message and the food and water they were left
  29. with before they ran out of energy:
  30. "You will run out of energy. You will be left with {food} food and {water} water."
  31. Input / Constraints
  32. • On the 1st line, you are going to receive a number N - the days of the adventure – an integer in the range [1…100]
  33. • On the 2nd line – the count of players – an integer in the range [0 – 1000]
  34. • On the 3rd line - the group’s energy – a real number in the range [1 - 50000]
  35. • On the 4th line – water per day for one person – a real number [0.00 – 1000.00]
  36. • On the 5th line – food per day for one person – a real number [0.00 – 1000.00]
  37. • On the next N lines – one for each of the days – the amount of energy loss– a real number in the range [0.00 - 1000]
  38. • You will always have enough food and water.
  39. Output
  40. • "You are ready for the quest. You will be left with - {energyLevel} energy!" –
  41. if they have enough energy
  42. "You will run out of energy. You will be left with {food} food and {water} water."
  43. • All of the real numbers should be formatted to the second digit after the decimal separator
  44.  
  45. Examples:
  46. Input:      Output:
  47. 10          You are ready for the quest. You will be left with - 658.72 energy!
  48. 7
  49. 5035.5
  50. 11.3
  51. 7.2
  52. 942.3
  53. 500.57
  54. 520.68
  55. 540.87
  56. 505.99
  57. 630.3
  58. 784.20
  59. 321.21
  60. 456.8
  61. 330
  62.  
  63. Comments:
  64. The days are 10 and the players are 7. The energy of the whole group is 5035.5.
  65. We receive the water and food and we can calculate the needed amount of both for the whole quest:
  66. 10 * 7 * 11.3 – total water = 791
  67. 10 * 7 * 7.2 – total food = 504
  68. Afterwards, for each of the days you have to calculate the energy loss.
  69. On each day you receive energy loss and you have to subtract it. On the first day it is:
  70. 5035.5 – 942.3 = 4093.2
  71. On every second day we add the energy boost from the drank water,
  72. which is 5% of the current energy and subtract the amount from the total water.
  73. The first time we reach a second day, the energy will become 3772.26 and the water will become 553.7.
  74. The first time we reach a third day,
  75. we have to boost the energy with 10% and reduce the food supplies and the energy will become - 3576.74 and the food 432.
  76. Make all of the calculations and in the end, you must have 658.77 energy left and 132.94 water and 317.39 food left.
  77. """
  78. days = int(input())
  79. players = int(input())
  80. energy = float(input())
  81. water = days * players * float(input())
  82. food = days * players * float(input())
  83.  
  84. for i in range(1, days + 1):
  85.     energy -= float(input())
  86.  
  87.     if energy <= 0:
  88.         break
  89.     if i % 2 == 0:
  90.         water *= 0.7
  91.         energy *= 1.05
  92.     if i % 3 == 0:
  93.         food -= food / players
  94.         energy *= 1.1
  95. if energy > 0:
  96.     print(f"You are ready for the quest. You will be left with - {energy:.2f} energy!")
  97. else:
  98.     print(f"You will run out of energy. You will be left with {food:.2f} food and {water:.2f} water.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement