407186: GYM102697 157 Computing Sin

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

157. Computing Sintime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output

While the equation of sin is highly stressed in high school math class, the methods for computing the sin of any input algebraically is usually not explained. There are various methods that can be used by computers or by hand, though the Taylor Approximation and CORDIC methods are most common. Calculators use CORDIC for its high speed and accuracy, though this problem will cover the Taylor Approximation method. If you have not yet had experience with calculus or the Taylor series, a Taylor Approximation is essentially a way to represent a function as a series of polynomial expressions. The use or details of this concept is not relevant to the question, though it is important to not that a Taylor Series will approximation its original function. In the case of the sin operation, the Taylor Approximation can be found as $$$x - \frac{x^3}{3!} + \frac{x^5}{5!} - \frac{x^7}{7!} + \frac{x^9}{9!}...$$$ The pattern can be repeated continuously to increase the accuracy of the approximation, and the approximation will only work on smaller radian values of input. In addition, if you have not seen the $$$!$$$ operator before, it is known as the factorial. The factorial of a number can be computed as the number multiplied by each integer below it, so $$$3! = 3*2*1 = 6$$$. For this problem, you will be provided with number of terms to use for the Taylor Approximation along with a radian angle value for input into the equation. You should then output the approximation for sin of this input value using the given number of terms of the Taylor Approximation.

Input

The first line will contain a single integer that represents the number of terms of the Taylor Approximation to use. The second line will have a single radian value that is to be input into the equation.

Output

A single floating point value that represents the approximation of sin with the given number of equation terms and the given input value.

ExampleInput
5
1
Output
0.8414710097001764

加入题单

算法标签: