QOJ.ac

QOJ

時間限制: 1 s 記憶體限制: 128 MB 總分: 100

#12684. Lemon Tree Under the Moon

统计

Li Zhe loves lemon trees very much. Especially on quiet nights, when a crescent moon gently illuminates the scenery on the ground, he will leisurely sit by the lemon tree he planted himself and ponder the philosophy of life.

Li Zhe is a child who loves to think. When he saw how clear the shadow cast by the lemon tree on the ground was under the moonlight, he immediately thought of a question: what is the area of the tree's shadow?

Li Zhe knows that measuring the area directly is very difficult, so he wants to use geometric methods to calculate it, as he understands the shape of this lemon tree very well and has already devised a simplified method.

Li Zhe divided the entire lemon tree into $n$ layers, numbered $1, 2, \dots, n$ from bottom to top. From layer $1$ to $n-1$, each layer is a frustum of a cone, and the $n$-th layer (the top layer) is a cone. For the frustums, both the upper and lower bases are horizontal circles. For two adjacent frustums, the lower base of the upper layer coincides with the upper base of the lower layer. The base of the $n$-th layer (the top layer) cone is the upper base of the $(n-1)$-th layer frustum. The centers of all bases (including the tree top) lie on the same line perpendicular to the ground. Li Zhe knows the height of each layer $h_1, h_2, \dots, h_n$, the height of the lower base of the first layer from the ground $h_0$, and the radius of the lower base of each layer $r_1, r_2, \dots, r_n$. Li Zhe used a well-known method to measure the angle between the moonlight and the ground as $\alpha$.

For ease of calculation, assume that the moonlight is parallel light and the ground is horizontal. Ignore the shadow cast by the trunk during the calculation. Li Zhe can certainly calculate it, but he hopes you will also practice.

Figure 1: Longitudinal cross-section of the lemon tree

Figure 2: Schematic diagram of the moonlight angle

Input

The first line contains an integer $n$ and a real number $\alpha$, representing the number of layers of the lemon tree and the angle between the moonlight and the ground (in radians).

The second line contains $n+1$ real numbers $h_0, h_1, h_2, \dots, h_n$, representing the height of the tree from the ground and the height of each layer.

The third line contains $n$ real numbers $r_1, r_2, \dots, r_n$, representing the radius of the lower base of each layer of the lemon tree.

The data in the input file are separated by a space between two adjacent numbers on the same line. All real numbers in the input may contain 1 to 10 significant digits after the decimal point.

Output

Output a single real number representing the area of the tree's shadow, rounded to two decimal places.

Examples

Input 1

2 0.7853981633 
10.0 10.00 10.00 
4.00 5.00

Output 1

171.97

Constraints

$1 \le n \le 500$, $0.3 < \alpha < \pi/2$, $0 < h_i \le 100$, $0 < r_i \le 100$.

  • 10% of the data: $n=1$.
  • 30% of the data: $n \le 2$.
  • 60% of the data: $n \le 20$.
  • 100% of the data: $n \le 500$.

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.