Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- n = int(input())
- dots = []
- while n:
- dots.append(tuple(map(int, input().split())))
- n -= 1
- res = 0
- for i in range(len(dots)):
- x = abs(dots[i][0] - dots[i-1][0])
- y = abs(dots[i][1] - dots[i-1][1])
- if min(x, y) == 0:
- res += max(x, y)
- else:
- while x % y > 0:
- x, y = y, x % y
- res += y
- print(res)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement