Integral Points In Triangle
Submissions: 245   Accuracy:

44.47%

  Difficulty: Easy   Marks: 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

 

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

Author: Rohan Malhotra


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 ide.geeksforgeeks.org, generate link and share the link here.


to report an issue on this page.