반응형
https://www.acmicpc.net/problem/2166
n = int(input())
points = []
for i in range(n):
points.append(list(map(int, input().split())))
# add first point again for the line connecting the beginning and the end.
points.append(points[0])
area = 0
for i in range(n):
cur_x, cur_y = points[i][0], points[i][1]
next_x, next_y = points[i+1][0], points[i+1][1]
area += (cur_x + next_x)*(cur_y - next_y)
print(round(abs(area*0.5), 2))
https://www.mathopenref.com/coordpolygonarea2.html
댓글