Count Integral Points
Submissions: 774   Accuracy:


  Difficulty: Medium   Marks: 4

Given two points p (x1, y1) and q (x2, y2), calculate the number of integral points lying on the line joining them.

Input: First line of the input is the number of test cases T.  Every test case has one input line.   The line contains 4 inputs which are x coordinate of p, y coordinate of p, x coordinate of q and y coordinate of 1.

Output:  Number of integral points between p and q

Constraints:  0 <= x1, y1, x2, y2 <= 1000

2 2 5 5
1 9 8 16


** For More Input/Output Examples Use 'Expected Output' option **

Author: kartik

If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.

Need help with your code? Please use, generate link and share the link here.

to report an issue on this page.