lattice
InterviewTime limit1sMemory limit512 MB
Given three non-collinear integer points with coordinates up to 2^1024, count the lattice points on the triangle's perimeter, including the vertices.
- Level
Medium4 of 10
- Topics
- Math, Number theory, Geometry, Implementation
- Solved
- No attempts yet
Problem
Write a function P1:
-
A point is called a lattice point iff both and are integers.
-
input parameter: integers
x1,y1,x2,y2,x3,y3- Three points (
x1,y1), (x2,y2), (x3,y3) are not on a same straight line. - The absolute value of each input parameter is less than or equal to .
- Three points (
-
return value: the number of the lattice points (including vertexes) on the perimeter of the triangle with three vertexes (
x1,y1), (x2,y2), (x3,y3)- For example, if a triangle has vertexes then its perimeter has 6 lattice points: .