PivotOJ

Downsizing

시간 제한: 1000ms메모리 제한: 1024MB출처: ICPC ECNA 2021-2022BOJ 24558

문제

Renowned nuclear physicist Adam Szmasczer has found a solution to global overpopulation and scarce resources: shrink everything! More precisely, he has found a way to teleport regions of space (both bounded and unbounded) to a bounded set of points inside a finite spherical cell. He explains his process as follows (from here on, we will work only in two dimensions for simplicity).

Assume a circular cell of radius rr is centered at a point OO. Let PP be any point not in the interior of the cell, and suppose the line OP\overline{OP} intersects the cell's boundary at the point BB. Then point PP is teleported to a point PP' lying on this line, where length(OP)length(OP)=r2\text{length}(\overline{OP})\cdot\text{length}(\overline{OP'}) = r^2. (Points along the cell boundary are teleported to themselves.) Figure D.1 shows how a pentagonal "house" is teleported to the shaded area within the circle; sample points OO, PP, PP', and BB are identified in the figure to illustrate the teleportation rule.

Figure D.1: Sample input 1, illustrating the downsizing process

Given a convex polygonal shape not containing any interior point of the cell, Adam would like to know the area of the corresponding teleported shape. Can you help?

입력

The first line of input contains three integers x0x_0, y0y_0, and rr, 104x0,y0,r104-10^4 \leq x_0,y_0,r \leq 10^4, specifying the center of the circular cell and its radius. (The entire circular cell lies within the specified bounds.) The second line of input contains a positive integer nn, 3n1003 \leq n \leq 100, followed by nn pairs of integers x1x_1, y1y_1, x2x_2, y2y_2, \ldots, xnx_n, yny_n, 104xi,yi104-10^4 \leq x_i, y_i \leq 10^4, giving the vertices of a convex polygon with nn vertices in counterclockwise order.

출력

Output the area of the region of the cell corresponding to the rectangular region in the input. Your answer should be correct to a relative or absolute error of 10610^{-6}.

예제

예제 1

입력
3 3 5
5 11 9 9 6 9 1 13 1 13 6
출력
4.112904
코드를 제출하려면 로그인하세요.