#t232. 分段函数
分段函数
Piecewise Function
Problem Description
Write a program to compute the value of the following piecewise function .
$$\begin{cases} y=-x+2.5,\quad &0 \le x \lt 5\\ y=2-1.5(x-3)(x-3),\quad &5 \le x \lt 10\\ y={x\over 2}-1.5,\quad &10 \le x \lt 20 \end{cases}$$Input Format
A floating-point number , .
Output Format
Output the value of the piecewise function at : , kept to three decimal places.
Sample Input
1.0
Sample Output
1.500
Hint
- Each of the three intervals uses its own formula; get the endpoint assignment right: which segment does fall into? Which does fall into?
- Keep decimal places.
- Verify with the sample:
1.0→1.500.