34 lines
449 B
C
34 lines
449 B
C
|
#include <math.h>
|
||
|
#include <stdio.h>
|
||
|
|
||
|
static long long unsigned c;
|
||
|
static long double eps;
|
||
|
|
||
|
static long double x;
|
||
|
static long long unsigned n;
|
||
|
|
||
|
int next()
|
||
|
{
|
||
|
long double p = x;
|
||
|
x = (p + (c / p)) / 2;
|
||
|
n++;
|
||
|
return fabsl(x - p) >= eps;
|
||
|
}
|
||
|
|
||
|
void print()
|
||
|
{
|
||
|
printf("x_%llu=%Lf, ", n, x);
|
||
|
}
|
||
|
|
||
|
int main()
|
||
|
{
|
||
|
scanf("%llu %Lf", &c, &eps);
|
||
|
x = c;
|
||
|
n = 0;
|
||
|
print();
|
||
|
while (next())
|
||
|
print();
|
||
|
print();
|
||
|
return 0;
|
||
|
}
|