본문 바로가기

problem solving/Problem Solving

Triangle


http://acm.pku.edu.cn/JudgeOnline/problem?id=2954

Description

A lattice point is an ordered pair (x, y) where x and y are both integers. Given the coordinates of the vertices of a triangle (which happen to be lattice points), you are to count the number of lattice points which lie completely inside of the triangle (points on the edges or vertices of the triangle do not count).

Input

The input test file will contain multiple test cases. Each input test case consists of six integers x1, y1, x2, y2, x3, and y3, where (x1, y1), (x2, y2), and (x3, y3) are the coordinates of vertices of the triangle. All triangles in the input will be non-degenerate (will have positive area), and −15000 ≤ x1, y1, x2, y2, x3, y3 ≤ 15000. The end-of-file is marked by a test case with x1y1 = x2 = y2 = x3 = y3 = 0 and should not be processed.

Output

For each input case, the program should print the number of internal lattice points on a single line.

Source

Stanford Local 2004


Solving

격자상의 세 개의 정수좌표가 주어지면 이 좌표를 꼭지점으로 하는 삼각형 내에 존재하는 정수좌표의 수를 구하여라.

'problem solving > Problem Solving' 카테고리의 다른 글

Barbara Bennett's Wild Numbers  (0) 2008.10.12
Cake Cutting  (0) 2008.10.10
Square  (0) 2008.10.07
Ubiquitous Religions  (0) 2008.10.07
MPI Maelstrom  (0) 2008.10.07