Skip to main content
Tuesday (24.11.2026) at 20:00: ALGOR Contest: Round #4 (Special Challenge) starts!

~/algor $ cat problems/for-sinus-qatori

Sine series

Medium 1000 ms 64 MB 46%
Share

A real number $x$ (in radians) and a positive integer $N$ are given. Compute $\sin x$ as the sum of the first $N$ terms of the series:

$$S = x - \frac{x^{3}}{3!} + \frac{x^{5}}{5!} - \frac{x^{7}}{7!} + \dots$$

The $k$-th term ($k = 1, 2, \dots, N$) equals $\frac{(-1)^{k-1} * x^{2k-1}}{(2k-1)!}$.

The terms of the Taylor series of sine

Input

One line with a real number $x$ and a positive integer $N$.

Output

One number — $S$, with exactly 6 digits after the decimal point (for example, 0.841667).

Note

$-3.14 \le x \le 3.14$
$x$ has at most $2$ digits after the decimal point
$1 \le N \le 10$

Examples

Input #1
1 3
Output #1
0.841667
Input #2
0.5 2
Output #2
0.479167

Sign in to submit a solution

Signing up is free and takes a minute.