import java.util.*;
import java.lang.*;
import java.io.*;
import java.lang.Math;
class Main
{
{
Scanner in
=new Scanner
(System.
in); double x, sum = 1, delta, elem = 1;
x=in.nextDouble();
delta=in.nextDouble();
double co
= Math.
cos(x
), rs
= 1 + delta
; for (int i = 1; rs > delta; i++)
{
elem *= - x * x / (2 * i * (2 * i - 1)); //рекурсивно выражаем каждый элемент суммы
sum += elem; // сумируем
rs
= Math.
abs(co
- sum
); // вычисляем модуль разницы для оценки точности System.
out.
printf("Step: %d %8.6f \n", i, sum
); // выводим номер шага и значение суммы на этом шаге }
System.
out.
printf("Value: %8.6f ~ %8.6f", sum, co
); //выводим конечное значение }
}
CmltcG9ydCBqYXZhLnV0aWwuKjsKaW1wb3J0IGphdmEubGFuZy4qOwppbXBvcnQgamF2YS5pby4qOwppbXBvcnQgamF2YS5sYW5nLk1hdGg7CgpjbGFzcyBNYWluCnsKCXB1YmxpYyBzdGF0aWMgdm9pZCBtYWluIChTdHJpbmdbXSBhcmdzKSB0aHJvd3MgamF2YS5sYW5nLkV4Y2VwdGlvbgoJewoJCVNjYW5uZXIgaW49bmV3IFNjYW5uZXIoU3lzdGVtLmluKTsKCQlkb3VibGUgeCwgc3VtID0gMSwgZGVsdGEsIGVsZW0gPSAxOyAKCQl4PWluLm5leHREb3VibGUoKTsKCQlkZWx0YT1pbi5uZXh0RG91YmxlKCk7CgkJZG91YmxlIGNvID0gTWF0aC5jb3MoeCksIHJzID0gMSArIGRlbHRhOwoJCWZvciAoaW50IGkgPSAxOyBycyA+IGRlbHRhOyBpKyspCgkJewoJCQllbGVtICo9IC0geCAqIHggLyAoMiAqIGkgKiAoMiAqIGkgLSAxKSk7IC8v0YDQtdC60YPRgNGB0LjQstC90L4g0LLRi9GA0LDQttCw0LXQvCDQutCw0LbQtNGL0Lkg0Y3Qu9C10LzQtdC90YIg0YHRg9C80LzRiwoJCQlzdW0gKz0gZWxlbTsgLy8g0YHRg9C80LjRgNGD0LXQvAoJCQlycyA9IE1hdGguYWJz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