#include <stdio.h>
int main() {
// рабочие переменные
double s = 0;
int i, n ;
double b, x, xPrev = 0, xPrev2 = 0, xPrev3 = 0;
int k;
if( scanf("%d", &n) <= 0 )
{
printf("error: missing n\n" );
return 0;
}
if( n <= 0 )
{
printf("error: out of range: n=%d\n", n);
return 0;
}
// основной цикл сравнения
for( i = 1, b = 2; i <= n; i++, b *= 2 )
{
if( i > 3 ) xPrev3 = xPrev2;
if( i > 2 ) xPrev2 = xPrev;
if( i > 1 ) xPrev = x;
if( i < 4 )
{
x = 1;
}
else
{
x = xPrev + xPrev3;
}
s += x / b;
}
// вывод результата
printf("result: %lf\n", s );
return 0;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CgoKaW50IG1haW4oKSB7CgogICAvLyDRgNCw0LHQvtGH0LjQtSDQv9C10YDQtdC80LXQvdC90YvQtQogICBkb3VibGUgcyA9IDA7CiAgIGludCBpLCBuIDsKICAgIAogICBkb3VibGUgYiwgeCwgeFByZXYgPSAwLCB4UHJldjIgPSAwLCB4UHJldjMgPSAwOwogICBpbnQgazsKCiAgIGlmKCBzY2FuZigiJWQiLCAmbikgPD0gMCApCiAgIHsKICAgICAgcHJpbnRmKCJlcnJvcjogbWlzc2luZyBuXG4iICk7CiAgICAgIHJldHVybiAwOwogICB9CiAgIAogICBpZiggbiA8PSAwICkKICAgewogICAgICBwcmludGYoImVycm9yOiBvdXQgb2YgcmFuZ2U6IG49JWRcbiIsIG4pOwogICAgICByZXR1cm4gMDsKICAgfQogICAKICAgLy8g0L7RgdC90L7QstC90L7QuSDRhtC40LrQuyDRgdGA0LDQstC90LXQvdC40Y8gICAKICAgZm9yKCBpID0gMSwgYiA9IDI7IGkgPD0gbjsgaSsrLCBiICo9IDIgKQogICB7CiAgICAgIGlmKCBpID4gMyApIHhQcmV2MyA9IHhQcmV2MjsKICAgICAgaWYoIGkgPiAyICkgeFByZXYyID0geFByZXY7ICAgCiAgICAgIGlmKCBpID4gMSApIHhQcmV2ID0geDsgIAogICAgIAogICAgICBpZiggaSA8IDQgKQogICAgICB7CiAgICAgICAgeCA9IDE7CiAgICAgIH0KICAgICAgZWxzZQogICAgICB7CiAgICAgICAgeCA9IHhQcmV2ICsgeFByZXYzOwogICAgICB9CgogICAgICBzICs9IHggLyBiOwogICB9CgogICAvLyDQstGL0LLQvtC0INGA0LXQt9GD0LvRjNGC0LDRgtCwCiAgIHByaW50ZigicmVzdWx0OiAlbGZcbiIsIHMgKTsKICAgcmV0dXJuIDA7Cn0=