The Lonely Shepherdess
dalarna
In the province of Dalarna, Sweden, there is a high mountain. On the mountain, there is a small cabin where a shepherdess lives. Every morning, the sound of a melodious flute drifts from the neighboring mountain, and the shepherdess responds with her own singing from inside the cabin.
The floor plan of the cabin is a simple polygon with $n$ vertices. Each wall can reflect sound, but due to inevitable energy loss, it can reflect sound at most $k$ times ($k=0$ means sound cannot be reflected). The walls are very smooth, so the reflection of sound follows the law that the angle of reflection equals the angle of incidence, as shown in Figure 1. Corners cannot reflect sound, but all other parts of each wall—even those very close to a corner—can reflect sound.
Figure 1. Reflection of sound
One day, the shepherdess asks herself: In which parts of the cabin can her singing be heard? Assuming all listeners are sitting against the walls inside the cabin, what is the total length of the walls that the singing can reach?
The four diagrams in Figure 2 show the initial situation and the regions reached by sound after 0, 1, and 2 reflections, respectively. The gray areas represent the parts where the singing can be heard, and the black dot represents the position of the shepherdess. The goal of this problem is to find the total length of the gray parts along the boundary of the polygon.
Figure 2. Regions where the singing can be heard
Input
The first line contains four integers $n$, $k$, $x$, and $y$, representing the number of corners of the cabin, the maximum number of reflections, and the coordinates of the shepherdess (the shepherdess is guaranteed to be inside the cabin and at least 1 unit away from any wall). The following $n$ lines each contain two integers $x, y$, representing the coordinates of the $i$-th corner. The corners are listed in clockwise or counter-clockwise order.
Output
The output should contain a single real number $L$, representing the total length of the walls where the singing can be heard. Round the result to two decimal places.
Examples
Input 1
5 0 100 135 20 200 200 100 300 125 40 10 100 100
Output 1
469.86
Input 2
8 1 25 15 0 0 0 20 30 20 30 0 20 0 20 10 10 10 10 0
Output 2
106.67
Subtasks
If the absolute difference between the contestant's output and the reference output is no more than $0.02$, the test case is awarded full points. If the difference is greater than $0.02$ but no more than $1$, the test case is awarded $50\%$ of the points. In Example 1, answers between $469.84$ and $469.88$ receive full points, while $468.86$ and $470.86$ receive $50\%$ of the points.
Constraints
$3 \le n \le 50$, $0 \le k \le 5$, all coordinates are integers with absolute values not exceeding $1000$. $50\%$ of the data satisfies $k \le 1$.