Подразделы

Другие разделы

Дата и время

19/12/2024 22:43:23

Авторизация

Имя:
Пароль:
Зарегистрироваться
Восстановить пароль
 

printPentium vs ENIAC

Ограничения: время – 1s/2s, память – 32MiB Ввод: input.txt или стандартный ввод Вывод: output.txt или стандартный вывод copy
Послать решение Blockly Посылки Темы Где Обсудить (0)

The calculation of 2000 digits of number `π` on the computer ENIAC in 1949 took 70 hours (not including programming!). Modern computers (and programmers) can find 2000 digits of number `π` much faster.
For calculation a series should be used
   `π/4\ =\ 1\ -\ 1/3\ +\ 1/5\ -\ 1/7\ +\ 1/9\ -\ …`
But this series converges slowly. Much better is series for an arctangent
   `"arctg"\ x\ =\ x\ -\ x^3/3\ +\ x^5/5\ -\ x^7/7\ +\ …,\ |x|<1`.
Combine it with the formula for addition of a tangent
   `"tg"(a+b)\ =\ ("tg"\ a\ +\ "tg"\ b)/(1\ -\ "tg"\ a\ *\ "tg"\ b)`
and select `a` and `b` so that `"tg"\ (a+b)\ =\ 1\ =\ "tg"\ π/4`. In practice usually use the following formulas
   `π\ =\ 16\ "arctg"\ (1/5)\ -\ 4\ "arctg"\ (1/239)`
   `π\ =\ 32\ "arctg"\ (1/10)\ -\ 16\ "arctg"\ (1/515)\ -\ 4\ "arctg"\ (1/239)`
   `π\ =\ 12\ "arctg"\ (1/4)\ +\ 4\ "arctg"\ (1/20)\ +\ 4\ "arctg"\ (1/1985)`
In all formulas it is necessary to calculate `"arctg"\ (1/k)`, where `k\ ≥\ 2`. Write the program that fulfills this calculation.
Input
The first line of the input file contains one integer `k` (`2\ ≤\ k\ ≤\ 10000`).
Output
Write into the output file a value of `"arctg"\ (1/k)` with accuracy `10^{-2000}`.

Sample Input

2

Sample Output

0.46364760900080611621425623146121440...399481324877580713052569525399998448
Условие задачи на русском языке
loading