#include using namespace std; using Q = float; // f(x) = a + bx using linear = pair; linear operator+(linear f, linear g) { return {f.first + g.first, f.second + g.second}; } linear operator+(linear f, Q a) { return {f.first + a, f.second}; } linear operator*(linear f, Q a) { return {f.first * a, f.second * a}; } linear operator/(linear f, Q a) { return {f.first / a, f.second / a}; } // f(x) = 0 Q solve(linear f) { return -f.first / f.second; } // f(a) Q eval(linear f, Q a) { return f.first + f.second * a; } int main() { int n; string s; cin >> n >> s; vector E(n + 1); vector f(n + 1); f[n - 1] = {0, 0}; f[n] = {0, 1}; for (int i = n - 2; i >= 0; i--) { if (s[i] == '#') { f[i] = {0, 1}; continue; } E[i] = solve((f[i + 1] + f[i + 2] + linear{0, -2}) / 3 + 1); f[i] = (f[i + 1] + f[i + 2] + E[i]) / 3 + 1; } cout << setprecision(20) << setiosflags(ios::fixed); cout << E[0] << "\n"; }