10171017 SUSTech Online Judge
Problem 1017 --Count Points

1017: Count Points

Time Limit: 1 Sec  Memory Limit: 128 MB
Submit: 569  Solved: 110
[Submit][Status][Web Board]

Description

Lucy asked Huang Bo a question, “You have two 2-D point A and B, please calculate how many integer points in segment A, B. For example, A(1, 3), B(3, 1) only has 1 integer point (2, 2)”.

Input

There are multiple test cases (less than 1000), for each test, there will be one line contain four integers ax, ay and bx, by, represent the point A and B

Notice that the absolute value of integer is 109.

Output

One line for each test case, write the number of integer point.

Sample Input

1 3 3 1
1 11 5 3
1 1 9 9

Sample Output

1
3
7

HINT

Bonus Problem. Math

Source

[Submit][Status]