Integral Points In Triangle
Easy Accuracy: 42.27% Submissions: 338 Points: 2

Given three non-collinear coordinates P(p1,p2), Q(q1,q2) and R(r1,r2) of a triangle in X-Y plane, find the number of integral / lattice points inside this triangle.(A point in XY plane is said to be integral / lattice point if both its co-ordinates are integral)

Input:
The first line of input contains an integer T denoting the number of test cases. Then T test cases follow. The first line of each test case contains an two integers (p1  p2), second line of the testcase contains ( q1  q2) and the third line of the testcase contains ( r1 & r2) denoting the coordinates P, Q, R respectively.

Output:
Print out the count of integral points lying inside the triangle .

Constraints:
1 <= T <= 100
-100 <= P, Q, R <=100

Examples: 
Input:
2
0 0
0 5
5 0
62 -3
5 -45
-19 -23

Output:
6
1129

 

to report an issue on this page.

Editorial

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

Yes

All Submissions

My Submissions:

Login to access your submissions.