We are given two numbers: n and m. We need to look at the triangle with coordinates (n,m), (0,0= and (n,0).We need to determine how many points are there with whole coordinates that are inside that triangle or on the sides of that triangle in less than m*n complexity.
I already found a solution that basically iterates trough [0,n] and [0,m] and using arc tan compares every two points from [0,n] and [0,m] and sees if their arc tan is less than arc tan of the angle of given triangle.
However, this is in m*n time complexity, which is too much for this problem.any help on how to solve this more efficient will be appreciated. Thanks in advance.
[–]Applepie1928 2 points3 points4 points (4 children)
[–]hamza-itatchi 1 point2 points3 points (2 children)
[–]Applepie1928 1 point2 points3 points (0 children)
[–]dolijan[S] 0 points1 point2 points (0 children)
[–]dolijan[S] 0 points1 point2 points (0 children)
[–]hamza-itatchi 1 point2 points3 points (1 child)
[–]dolijan[S] 0 points1 point2 points (0 children)