int main() { const int LEN = 100; double a[LEN], f[LEN]; a[0] = 1; a[1] = 0.5; a[2] = 0.5; double E = 0.0; for (int i = 3; i < LEN; ++i) { a[i] = 0.5*a[i - 2] + 0.125*a[i - 3]; } for (int i = 2; i < LEN; ++i) { f[i] = 0.25*a[i - 2]; E += i*f[i]; } cout<<E<<endl; return 0; }