#P4179. Hilbert Mole Burrow Flooding

    ID: 17426 Type: Default 1000ms 256MiB

Hilbert Mole Burrow Flooding

Hilbert Mole Burrow Flooding

The Hilbert mole lives in a burrow whose boundary is given by an n-order Hilbert curve \(H_n\). The Hilbert curve is defined recursively as follows: \(H_1\) is a unit square with its top side missing, and for \(n\ge 2\), \(H_n\) is built from four copies of \(H_{n-1}\) arranged in a special way: the lower‐left and lower‐right copies remain unchanged, the upper–left copy is rotated 90° counter–clockwise, and the upper–right copy is rotated 90° clockwise. These four copies are connected by three unit–length segments to form \(H_n\). (See figures below.)

You plan to catch a Hilbert mole for fun so you force–pour water into its burrow in an attempt to flush it out. However, because the burrow is filled with air (assume both water and air are incompressible), no matter how much water you pour, some regions never get flooded. In particular, water only flows over a barrier if its current water level is strictly greater than the barrier’s top (see the example below for details).

You are given the order \(n\) of the Hilbert curve (which is the boundary of the burrow) and the tilt angle \(\alpha\) (in degrees) of the ground. In this problem we adopt the following simplified model:

  • The burrow is modeled as a region whose effective floor elevation is linearly distributed with the vertical coordinate. In other words, if we set the unit length as defined by \(H_1\), then the floor elevation at any point is proportional to its y-coordinate. The tilt angle \(\alpha\) determines the elevation difference between two points a unit distance apart. (For simplicity, assume the elevation difference between two horizontal levels is \(\sin\alpha\) when \(\alpha\) is converted to radians.)
  • The water is poured through the open top gap of \(H_1\) (and accordingly the composite \(H_n\) has a single entrance at its top). The water in the flooded region maintains a constant level, equal to the floor elevation at the entrance. Water can pass from one compartment to a neighboring one only if the barrier between them (assumed to have the height equal to the maximum of the floor elevations of the two compartments along that boundary) is strictly below the water level.
  • Under these assumptions, it turns out that the flooded area \(A\) (the area that can be reached by water pouring in from the top gap) can be computed by the formula \[ A = 1 - \cos^n\theta, \] where \(\theta\) is the tilt angle in radians. (This formula is derived by a recursion that mimics the self–similar structure of the Hilbert curve.)

Your task is: Given the integer \(n\) and the tilt angle \(\alpha\) (in degrees), compute the flooded area \(A\). Print the result as a floating–point number with six digits after the decimal point.

Note: All formulas must be displayed in proper \(\LaTeX\) format.

Hilbert curve illustration
Flooding example

inputFormat

The input consists of a single line containing an integer \(n\) (with \(n \ge 1\)) and a real number \(\alpha\) (in degrees). For example:

1 0

represents a Hilbert curve of order 1 with a tilt angle of 0 degrees.

outputFormat

Output the flooded area \(A\) as a floating–point number rounded to six digits after the decimal point.

For example, if the computed area is 0.5, then output:

0.500000

sample

1 0
0.000000

</p>