====== Triangle ====== ===== 풀이 ===== * [[ps:이론:다각형#다각형 내부의 격자점의 갯수|픽의 정리]]를 이용해서 삼각형 내부의 격자점의 갯수를 구하는 문제 * [[ps:problems:boj:27123]]에서 삼각형의 밑변이 x축 위에 있어야 된다는 조건만 빠진 버전이다. ===== 코드 ===== """Solution code for "BOJ 7694. Triangle". - Problem link: https://www.acmicpc.net/problem/7694 - Solution link: http://www.teferi.net/ps/problems/boj/7694 Tags: [geometry] [pick's theorem] """ import sys from teflib import geometry def main(): while (line := sys.stdin.readline().rstrip()) != '0 0 0 0 0 0': x1, y1, x2, y2, x3, y3 = [int(x) for x in line.split()] polygon = [(x1, y1), (x2, y2), (x3, y3)] interior_points, _ = geometry.lattice_point_in_polygon(polygon) print(interior_points) if __name__ == '__main__': main() * Dependency: [[:ps:teflib:geometry#lattice_point_in_polygon|teflib.geometry.lattice_point_in_polygon]] {{tag>BOJ ps:problems:boj:골드_3}}