import java.util.*;
import java.lang.*;
import java.io.*;
class SumApp
{
public static Integer scanInteger
( Scanner in
) {
return ( ( in.hasNextInt() ) ? in.nextInt() : null );
}
public static void main
( String[] args
) {
// рабочие переменные
int i;
double s = 0;
double b, x = 0, xPrev = 0, xPrev2 = 0, xPrev3 = 0;
Scanner in
= new Scanner
(System.
in);
n = scanInteger( in );
in.close();
if( n == null || n <= 0 )
{
System.
err.
printf("error: missing or out of range: n=%d\n", n
); return;
}
// основной цикл сравнения
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;
}
// вывод результата
System.
out.
printf("result: %f\n", s
); }
}
aW1wb3J0IGphdmEudXRpbC4qOwppbXBvcnQgamF2YS5sYW5nLio7CmltcG9ydCBqYXZhLmlvLio7CiAKY2xhc3MgU3VtQXBwCnsKICAgcHVibGljIHN0YXRpYyBJbnRlZ2VyIHNjYW5JbnRlZ2VyKCBTY2FubmVyIGluICkKICAgewogICAgICAgcmV0dXJuICggKCBpbi5oYXNOZXh0SW50KCkgKSA/IGluLm5leHRJbnQoKSA6IG51bGwgKTsKICAgfQogICAKICAgcHVibGljIHN0YXRpYyB2b2lkIG1haW4oIFN0cmluZ1tdIGFyZ3MgKQogICB7ICAKICAgICAgLy8g0YDQsNCx0L7Rh9C40LUg0L/QtdGA0LXQvNC10L3QvdGL0LUKICAgICAgSW50ZWdlciBuID0gbnVsbDsKICAgICAgaW50IGk7CiAgICAgIGRvdWJsZSBzID0gMDsKICAgICAgZG91YmxlIGIsIHggPSAwLCB4UHJldiA9IDAsIHhQcmV2MiA9IDAsIHhQcmV2MyA9IDA7CiAgICAgIAogICAgICBTY2FubmVyIGluID0gbmV3IFNjYW5uZXIoU3lzdGVtLmluKTsKICAgICAgCiAgICAgIG4gPSBzY2FuSW50ZWdlciggaW4gKTsKICAgICAgCiAgICAgIGluLmNsb3NlKCk7IAoKICAgICAgCiAgICAgIGlmKCBuID09IG51bGwgfHwgbiA8PSAwICkKICAgICAgewogICAgICAgICBTeXN0ZW0uZXJyLnByaW50ZigiZXJyb3I6IG1pc3Npbmcgb3Igb3V0IG9mIHJhbmdlOiBuPSVkXG4iLCBuKTsKICAgICAgICAgcmV0dXJuOwogICAgICB9CiAgICAgIAogICAgICAvLyDQvtGB0L3QvtCy0L3QvtC5INGG0LjQutC7INGB0YDQsNCy0L3QtdC90LjRjyAgIAogICAgICBmb3IoIGkgPSAxLCBiID0gMjsgaSA8PSBuOyBpKyssIGIgKj0gMiApCiAgICAgIHsKICAgICAgICAgaWYoIGkgPiAzICkgCiAgICAgICAgIHsKICAgICAgICAgICAgeFByZXYzID0geFByZXYyOwogICAgICAgICB9CiAgICAgICAgIGlmKCBpID4gMiApIAogICAgICAgICB7CiAgICAgICAgICAgIHhQcmV2MiA9IHhQcmV2OyAgIAogICAgICAgICB9ICAgCiAgICAgICAgIGlmKCBpID4gMSApCiAgICAgICAgIHsKICAgICAgICAgICAgeFByZXYgPSB4OyAKICAgICAgICAgfSAgICAgICAgICAKICAgICAgICAgaWYoIGkgPCA0ICkKICAgICAgICAgewogICAgICAgICAgIHggPSAxOwogICAgICAgICB9CiAgICAgICAgIGVsc2UKICAgICAgICAgewogICAgICAgICAgIHggPSB4UHJldiArIHhQcmV2MzsKICAgICAgICAgfQogICAgICAKICAgICAgICAgcyArPSB4IC8gYjsKICAgICAgfQogICAgICAKICAgICAgLy8g0LLRi9Cy0L7QtCDRgNC10LfRg9C70YzRgtCw0YLQsAogICAgICBTeXN0ZW0ub3V0LnByaW50ZigicmVzdWx0OiAlZlxuIiwgcyApOwogICB9Cn0=