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