It is known that:
$$ \sin{x} = \cos{(90^{\circ} - x)} = \sin{(180^{\circ} - x)} = -\cos{(90^{\circ} + x)} $$ $$ \cos{x} = \sin{(90^{\circ} - x)} = \sin{(90^{\circ} + x)} = -\cos{(180^{\circ} - x)} $$
Given a trigonometric expression in the form sin x
or cos x
(we omit the degree symbol for simplicity),
rewrite the expression into either sin x
or cos x
, with or without a preceding negative sign,
such that $|x|$ is minimized while the expressions are equivalent.
If (-)sin x
= (-)cos x
when x
is minimized, you should output (-)sin x
.
Hint: $|x| $ is at most $ 45^{\circ} $ after simplification.
Your code may work for most test cases but fail for some special test cases. These are commonly referred to as "corner cases". Your code will not be Accepted unless your code handles all cases within the constraints correctly.
Input
The only line of input contains an expression in the form of sin x
or cos x
, where x
is an integer.
($ 0 \le x \le 180 $)
Output
Output a trigonometric expression in the form described above. ($ x \ge 0 $)
Sample Test Cases
Input | Output | |
---|---|---|
cos 30 | cos 30 | |
sin 89 | cos 1 | |
cos 180 | -cos 0 |
Scoring: Per Case
Authored by s16f22
Appeared in Test Contest