#include "bits/stdc++.h" using namespace std; #define DEBUG(x) cout<<#x<<": "< #define vl vector #define vii vector< vector > #define vll vector< vector > #define vs vector #define pii pair #define pll pair #define pis pair #define psi pair const int inf = 1000000001; const ll INF = 1e16; #define MOD 1000000007 #define mod 1000000009 #define pi 3.14159265358979323846 #define Sp(p) cout<> n >> k; string s; cin >> s; for (i = n-1; i >= 0; i--) { if (s[i] == '0') { break; } } if (i == -1) { cout << 1 << endl; return 0; } s = s.substr(i, n - i) + s.substr(0, i); vi blue; int cnt = 0; for (i = 1; i < n; i++) { if (s[i] == '1') { cnt++; } else { blue.push_back(cnt); cnt = 0; } } blue.push_back(cnt); //cout << s << endl; //DEBUG_VEC(blue); //DEBUG_VEC(blue); int m = blue.size(); vi sum(2 * m + 1); sum[0] = 0; for (i = 1; i <= 2 * m; i++) { sum[i] = sum[i - 1] + blue[(i-1)%m]; } //DEBUG_VEC(sum); int left = 0, right = m; double ans = 0; while (left < right) { int mid = (left + right) / 2; int b = 0; if (mid == m) { ans = max(ans, (double)sum[m] / n); right = mid; } else { for (i = 0; i < m; i++) { b = max(b, sum[i + 1 + mid] - sum[i]); } if (b + mid >= k) { ans = max(ans, (double)b / (b + mid)); right = mid; } else { left = mid + 1; } } } Sp(ans); }