func_code_string: #include <bits/stdc++.h>   using namespace std;   int n, m, a[111], x[111], saven;   long double f[2][100111], sum[2][100111];   int main() {     ios ::sync_with_stdio(0);     cin.tie(0);     cout << (fixed) << setprecision(12);     while (cin >> n >> m) {       int sumA = 0;       for (int i = (1), _b = (n); i <= _b; ++i) {         int x;         cin >> x;         --x;         a[i] = x;         sumA += x;       }       if (m == 1) {         cout << 1.0 << endl;         continue;       }       for (int i = (1), _b = (n); i <= _b; ++i) {         int cur = i % 2;         memset(f[cur], 0, sizeof f[cur]);         if (i == 1) {           for (int val = 0, _a = (m * i); val < _a; ++val)             if (val < m && val != a[i]) f[cur][val] = 1;         } else {           for (int val = 0, _a = (m * i); val < _a; ++val) {             f[cur][val] = sum[1 - cur][val];             if (val >= m) f[cur][val] -= sum[1 - cur][val - m];             f[cur][val] -= f[1 - cur][val - a[i]];           }         }         for (int val = 0, _a = (m * (i + 1)); val < _a; ++val) {           sum[cur][val] = f[cur][val];           if (val > 0) sum[cur][val] += sum[cur][val - 1];         }       }       long double t = sum[n % 2][sumA - 1];       for (int turn = 0, _a = (n); turn < _a; ++turn) t /= (m - 1);       cout << t * (m - 1.0) + 1 << endl;     }   }   