| 2026 Spring UT CS104c Final Exam |
|---|
| Finished |
You are building a new roof for your shed. You've decided to design the roof so that its cross-section is shaped like the curve $$$\cos x$$$ for $$$x \in [-\pi/2, \pi/2]$$$ (recall that cosine increases monotonically from $$$0$$$ at $$$x = -\pi/2$$$ to $$$1$$$ at $$$x=0$$$, and then decreases monotonically back to $$$0$$$ at $$$x=\pi/2$$$).
To buttress the roof, you will install some wooden beams. Each beam can be represented as a line segment of slope $$$m$$$ that extends from $$$(0,0)$$$ to a point $$$(x, mx)$$$ touching the roof. You've computed the value of the slope $$$m$$$ needed in order for the roof to be structurally sound. Before heading to the hardware store to buy lumber, you need to know the value of $$$x$$$ for which $$$\cos x = mx$$$. Compute this value.
The only line of input contains a single real number $$$m$$$ $$$(0 \leq m \leq 10^9)$$$: the slope of the beams you plan to install under your roof.
Print a real number: the value of $$$x \in [0, \pi/2]$$$ for which $$$\cos x = mx$$$. It is guaranteed that this value exists and is unique. Your program will be judged correct if it differs from the judge's solution with relative or absolute error at most $$$10^{-9}$$$.
42.0
0.0238027792365755885839462280273
0
1.57079632682143710553646087646
428668410.596547564
2.35741026699542999267578125e-09
Hint: make sure you use double precision and print $$$x$$$ with many digits after the decimal point (at least nine) to meet the above precision requirement.
To get the value of $$$\pi$$$ in your program, you can use the following.
In C++:
const double PI = acos(-1.0);
In Java:
double PI = Math.PI;
In Python:
import math
PI = math.pi
| Name |
|---|


