#include <stdio.h>
#include <math.h>
double f(double x)
{
return pow(x, 3.0);
}
int main()
{
const double ANS = 1.0 / 4.0;
double a = 0.0;
int N, i;
double x, r1, r2, d;
for (N=1 ; fabs(a - ANS) >= 0.001; N++ ) {
d = 1.0 / (double)N;
r1 = f(0.0);
a = 0.0;
for (i=1, x=d; i<=N; i++, x+=d) {
r2 = f(x);
a += ((r1 + r2) * d) / 2.0;
r1 = r2;
}
}
printf("%f\n", a);
return 0;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxtYXRoLmg+CiAKZG91YmxlIGYoZG91YmxlIHgpCnsKCXJldHVybiBwb3coeCwgMy4wKTsKfQogCmludCBtYWluKCkKewoJY29uc3QgZG91YmxlIEFOUyA9IDEuMCAvIDQuMDsgCglkb3VibGUgYSA9IDAuMDsKCWludCBOLCBpOwoJZG91YmxlIHgsIHIxLCByMiwgZDsKCglmb3IgKE49MSA7IGZhYnMoYSAtIEFOUykgPj0gMC4wMDE7IE4rKyApIHsKCQlkID0gMS4wIC8gKGRvdWJsZSlOOwoJCXIxID0gZigwLjApOwoJCWEgPSAwLjA7CgkJZm9yIChpPTEsIHg9ZDsgaTw9TjsgaSsrLCB4Kz1kKSB7CgkJCXIyID0gZih4KTsKCQkJYSArPSAoKHIxICsgcjIpICogZCkgLyAyLjA7CgkJCXIxID0gcjI7CgkJfQoJfQoJcHJpbnRmKCIlZlxuIiwgYSk7CglyZXR1cm4gMDsKfQo=