QOJ.ac

QOJ

Time Limit: 1.0 s Memory Limit: 512 MB Total points: 100 Hackable ✓

#14841. Tower-viewing Tower-viewing Tower Tower Time is Up

Statistics

There are infinitely many bamboo stalks in the Lost Bamboo Forest. Youmu wishes to use the Roukanken to cut down some bamboo for cooking.

To simplify the problem, consider a two-dimensional plane where the bamboo stalks can be viewed as $+\infty$ straight lines, with equal spacing between adjacent stalks. Each bamboo stalk has the same inclination (i.e., the angle with the $x$-axis). The range of Youmu's slash can be viewed as a simple polygon.

Youmu will use the Roukanken to cut the bamboo along the edges of the simple polygon; all bamboo stalks located inside the polygon will fall and be collected by Youmu.

Now, Youmu wants to know the total length of the bamboo she has cut down.

Input

The first line contains an integer $n$ ($1 \le n \le 10^5$), representing the number of vertices of the polygon. The next $n$ lines each contain two real numbers $x_i, y_i$ ($0 \le |x_i|, |y_i| \le 10^4$), giving the coordinates of each point in clockwise order.

The last line contains two real numbers $\theta, a$ ($\theta \in [1, 179)$, $a \in [0.1, 100]$) describing the parameters of the bamboo forest.

All real numbers in the input are given to four decimal places. Additionally, it is guaranteed that the angle between any edge of the polygon and the $x$-axis is not $\theta$.

Output

Output a single real number representing the total length of the bamboo cut down.

Your answer $ans$ is considered correct if and only if it satisfies $\frac{|ans - std|}{\max(1.0, std)} \le 10^{-6}$ compared to the standard answer $std$.

Examples

Input 1

4
2.0000 2.0000
2.0000 -2.0000
-2.0000 -2.0000
-2.0000 2.0000
45.0000 1.0000

Output 1

22.6274169980

Input 2

8
0.0000 2.5000
1.0000 1.5000
2.5000 1.0000
2.0000 -1.0000
1.0000 -2.0000
-2.0000 -2.0000
-2.5000 1.0000
-1.0000 2.0000
60.0000 0.8000

Output 2

23.1662217484

Note

For Example 1, it is easy to see that the total length of the bamboo (the total length of the orange line segments) is $16\sqrt{2}$.

For Example 2, I have a truly marvelous explanation for this example, but the margin here is too small to contain it.

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.