Hide

Problem D
Magic Chain

You recently got your hands on the new hit game “Mega Monster Maze!” a board game made up of a series of square rooms, some of which contain monsters of various varieties. Some of the monsters roam around the room they are in and some are chained to a specific part of the room. Roaming monsters will fight you if they catch you meaning you can only spend a limited amount of time in their room. Chained monsters will fight you if you get within their range. In order to regain health in the game you need to rest. Of course this means you need to either find a room without any monsters or find a room with a chained monster that cannot reach you. You come across one such room. The monster is chained to a corner with a chain that is just as long as the side length of the room. The monster is thus confined to a quarter circular region leaving you plenty of room to rest.

\includegraphics[width=0.25\textwidth ]{diagram.png}
Figure 1: Diagram of the room (the shaded region indicates where the monster can reach)

Being the curious individual you are you wonder what proportion of the room is safe to rest in (i.e. what proportion can the monster not reach). You quickly recognize that it must be $1-\frac{\pi }{4}\approx 0.214601836602552$ since the region the monster can reach is a quarter of a circle with radius $1$ thus $\frac{\pi }{4}$ and since the room has $1$ square unit of area. You note that if you were to give each point in the room $x$ and $y$ coordinates with the corner the monster is chained to as $(0,0)$, then the points the monster can reach satisfy that $x^2 + y^2 \leq 1$ in other words the monster can reach a point if the $l_2$ norm of the point is at most $1$. Being the curious mathematician you are you now wonder what proportion of the room would be safe if the monster could instead reach any point with an $l_p$ norm at most $1$.

Can you write a program to determine the proportion of the room that would be safe to rest in if the monster was constrained by the $l_p$ norm?

Note: The $l_p$ norm is given by $||(x,y)||_p=\sqrt[p]{|x|^p+|y|^p}$. For example, the $l_1$ norm is $\sqrt[1]{|x|^1+|y|^1}=|x|+|y|$ and the $l_2$ norm is $\sqrt[2]{|x|^2+|y|^2}$.

Input

The input consists of a single line containing a single real number $p$ ($1 \leq p \leq 100$) with at most $5$ digits after the decimal point.

Output

Print a single line containing the proportion of the room that is safe to rest in with an absolute error of at most $10^{-7}$

Sample Input 1 Sample Output 1
1.0
0.5
Sample Input 2 Sample Output 2
2.0
0.214601836602552

Please log in to submit a solution to this problem

Log in