SHARE
TWEET

Untitled

mfgnik Jun 5th, 2020 817 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top