Advertisement
mfgnik

Untitled

Jun 6th, 2020
839
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.44 KB | None | 0 0
  1. def calculate_distance(point, ice_cream):
  2.     return point, 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.     print(calculate_distance((school + club) // 2, ice_cream))
  8. else:
  9.     print(min(
  10.         calculate_distance((school + club) // 2, ice_cream),
  11.         calculate_distance((school + club) // 2 + 1, ice_cream),
  12.         key=lambda x: x[1],
  13.     ))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement