gigafloyd

Задачите от 02.10.2025

Nov 4th, 2025
755
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 4.77 KB | Source Code | 0 0
  1. #1
  2.  
  3. searched_book = input()
  4. current_book = input()
  5. books_counter = 0
  6. book_is_found = False
  7. while current_book != "No More Books":
  8.     if current_book == searched_book:
  9.         book_is_found = True
  10.         break
  11.     books_counter += 1
  12.     current_book = input()
  13. if book_is_found:
  14.     print(f"You checked {books_counter} books and found it.")
  15. else:
  16.     print("The book you search is not here!")
  17.     print(f"You checked {books_counter} books.")
  18.  
  19.  
  20. #2
  21. maximum_bad_grades = int(input())
  22. current_task = input()
  23. bad_grades_counter = 0
  24. average_score = 0
  25. total_tasks_counter = 0
  26. last_task_name = ""
  27. got_too_many_bad_grades = False
  28. while current_task != "Enough":
  29.     current_grade = int(input())
  30.     if current_grade <= 4:
  31.         bad_grades_counter += 1
  32.         if bad_grades_counter == maximum_bad_grades:
  33.             got_too_many_bad_grades = True
  34.             break
  35.     average_score += current_grade
  36.     total_tasks_counter += 1
  37.     last_task_name = current_task
  38.     current_task = input()
  39. if got_too_many_bad_grades:  # if got_too_many_bad_grades == True
  40.     print(f"You need a break, {bad_grades_counter} poor grades.")
  41. else:
  42.     average_score /= total_tasks_counter
  43.     # average_score = average_score / total_tasks_counter
  44.     print(f"Average score: {average_score:.2f}")
  45.     print(f"Number of problems: {total_tasks_counter}")
  46.     print(f"Last problem: {last_task_name}")
  47.  
  48.  
  49.  
  50. #3
  51.  
  52. needed_money = float(input())
  53. money_in_hand = float(input())
  54. total_days_counter = 0
  55. spend_counter = 0
  56. spending_too_many_days_in_a_row = False
  57. while money_in_hand < needed_money:
  58.     action = input()
  59.     current_sum = float(input())
  60.     total_days_counter += 1
  61.     if action == "spend":
  62.         spend_counter += 1
  63.         if spend_counter == 5:
  64.             spending_too_many_days_in_a_row = True
  65.             break
  66.         money_in_hand -= current_sum
  67.         if money_in_hand < 0:
  68.             money_in_hand = 0
  69.     elif action == "save": #else
  70.         money_in_hand += current_sum
  71.         spend_counter = 0
  72. if spending_too_many_days_in_a_row:
  73.     print("You can't save the money.")
  74.     print(total_days_counter)
  75. else:
  76.     print(f"You saved the money for {total_days_counter} days.")
  77.  
  78. #4
  79.  
  80. target_steps = 10000
  81. total_steps = 0
  82. while total_steps < target_steps:
  83.     command = input()
  84.     if command == "Going home":
  85.         last_steps = int(input())
  86.         total_steps += last_steps
  87.         break
  88.     current_steps = int(command)
  89.     total_steps += current_steps
  90. difference = abs(target_steps - total_steps)
  91. if total_steps >= target_steps:
  92.     print("Goal reached! Good job!" )
  93.     print(f"{difference} steps over the goal!")
  94. else:
  95.     print(f"{difference} more steps to reach goal.")
  96.  
  97. #5
  98.  
  99. change = float(input())
  100. change = int(change * 100)
  101. coins_counter = 0
  102. while change > 0:
  103.     if change >= 200:
  104.         change -= 200
  105.     elif change >= 100:
  106.         change -= 100
  107.     elif change >= 50:
  108.         change -= 50
  109.     elif change >= 20:
  110.         change -= 20
  111.     elif change >= 10:
  112.         change -= 10
  113.     elif change >= 5:
  114.         change -= 5
  115.     elif change >= 2:
  116.         change -= 2
  117.     elif change == 1:
  118.         change -= 1
  119.     coins_counter += 1
  120. print(coins_counter)
  121.  
  122.  
  123. # 5.1
  124.  
  125. change = float(input())
  126. change = int(change * 100)
  127. coins_counter = 0
  128. coins_counter += change // 200
  129. change = change % 200
  130. coins_counter += change // 100
  131. change = change % 100
  132. coins_counter += change // 50
  133. change = change % 50
  134. coins_counter += change // 20
  135. change = change % 20
  136. coins_counter += change // 10
  137. change = change % 10
  138. coins_counter += change // 5
  139. change = change % 5
  140. coins_counter += change // 2
  141. change = change % 2
  142. if change == 1:
  143.     coins_counter += 1
  144. print(coins_counter)
  145.  
  146.  
  147. #6
  148.  
  149. width = int(input())
  150. length = int(input())
  151. total_pieces = width * length
  152. no_more_cake_left = False
  153. command = input()
  154. while command != "STOP":
  155.     current_pieces = int(command)
  156.     total_pieces -= current_pieces
  157.     if total_pieces < 0:
  158.         no_more_cake_left = True
  159.         break
  160.     command = input()
  161. if no_more_cake_left:
  162.     print(f"No more cake left! You need {abs(total_pieces)} pieces more.")
  163. else:
  164.     print(f"{total_pieces} pieces are left." )
  165.  
  166.  
  167. #7
  168.  
  169. width = int(input())
  170. length = int(input())
  171. heigth = int(input())
  172. there_is_more_free_space = True
  173. total_volume = width * length * heigth
  174. command = input()
  175. while command != "Done":
  176.     current_number_of_boxes = int(command)
  177.     total_volume -= current_number_of_boxes
  178.     if total_volume < 0:
  179.         there_is_more_free_space = False
  180.         break
  181.     command = input()
  182. if there_is_more_free_space: # if there_is_more_free_space == True
  183.     print(f"{total_volume} Cubic meters left.")
  184. else:
  185.     print(f"No more free space! You need {abs(total_volume)} Cubic meters more.")
Advertisement
Add Comment
Please, Sign In to add comment