Advertisement
mfgnik

Untitled

Jun 5th, 2020
983
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.62 KB | None | 0 0
  1. def calculate_distance(point, ice_cream):
  2.     return min(point % ice_cream, ice_cream - (point % ice_cream))
  3.  
  4.  
  5. school, club, ice_cream = map(int, input().split())
  6. if school % 2 == club % 2:
  7.     home = (school + club) // 2
  8.     print(home, calculate_distance(home, ice_cream))
  9. else:
  10.     first_home = (school + club) // 2
  11.     second_home = first_home + 1
  12.     first_distance = calculate_distance(first_home, ice_cream)
  13.     second_distance = calculate_distance(second_home, ice_cream)
  14.     if first_distance < second_distance:
  15.         print(first_home, first_distance)
  16.     else:
  17.         print(second_home, second_distance)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement