SimeonTs

SUPyF Exam 10.03.2019 - 01. Listmons delivery problem

Aug 13th, 2019
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.48 KB | None | 0 0
  1. """
  2. Basics OOP Principles
  3. Check your solution: https://judge.softuni.bg/Contests/Practice/Index/1511#0
  4.  
  5. SUPyF Exam 10.03.2019 - 01. Listmons delivery problem
  6.  
  7. Problem:
  8. Listmon is a delivery guy. He should deliver a barrels with a mystic liquid.
  9. He has got a truck but he is not good at math so he asks you to help him.
  10. You have a task to estimate how many barrels can be transported with the single truck.
  11. The shape is rectangular parallelepiped and the barrel's shape always will be circular cylinder.
  12. If at some point the truck get full, you should stop receiving  barrels data and print
  13. „Truck is full.{count_of_barrels} on board!“.
  14. Where the count_of_barrels are the barrels you have succesfuly loaded up.
  15. If you have succesfully loaded up all barrels without breaking up the program you should print –
  16. „All barrels on board.Capacity left - {volume_of_truck}.“
  17. where the volume_of_truck is the free volume space has left.
  18. Where the volume is formatetd up to 2 digit after decimal point.
  19. Input
  20. You will recieve on the first 3 lines:
  21. • a – width of the truck [floating  number]
  22. • b – depth of the truck [floating number]
  23. • c – height of the truck [floating number]
  24. On the next line you will recieve
  25. • n - number of barrels [integer number]
  26. For each barrel tou will receive:
  27. • r - radius of the barrel [floating  number]
  28. • h -  height of the barrel [floating  number]
  29.  
  30. Output
  31. If you have loaded up all barrels you should print
  32. • "All barrels on board. Capacity left - {volume_of_truck}."
  33. Formatted two digits after decimal point.
  34. If you have no space left in the truck you should print
  35. • "Truck is full. {count_of_barrels} on board!"
  36.  
  37. Examples:
  38. Input:
  39. 300
  40. 150
  41. 200
  42. 6
  43. 100
  44. 100
  45. 100
  46. 100
  47. 100
  48. 100
  49. 100
  50. 100
  51. 100
  52. 100
  53. 100
  54. 100
  55. Output:
  56. Truck is full. 2 on board!
  57. Input:
  58. 100
  59. 100
  60. 50
  61. 2
  62. 20
  63. 40
  64. 30
  65. 60
  66. Output:
  67. All barrels on board. Capacity left - 280088.51.
  68. """
  69.  
  70. import math
  71.  
  72. a = float(input())
  73. b = float(input())
  74. c = float(input())
  75.  
  76. n = int(input())
  77.  
  78. truck_volume = a * b * c
  79. count_barrels_on_board = 0
  80.  
  81. no_more_space = False
  82.  
  83. for barrel in range(1, n + 1):
  84.     r = float(input())
  85.     h = float(input())
  86.     v = math.pi * r * r * h
  87.     if truck_volume > v:
  88.         count_barrels_on_board += 1
  89.         truck_volume -= v
  90.     else:
  91.         no_more_space = True
  92.         break
  93.  
  94. if no_more_space:
  95.     print(f"Truck is full. {count_barrels_on_board} on board!")
  96. else:
  97.     print(f"All barrels on board. Capacity left - {truck_volume:.2f}.")
Add Comment
Please, Sign In to add comment