func_code_string: #include <bits/stdc++.h>   using namespace std;   int n, m, x[101];   double e[2][101 * 1001], sume[101 * 1001];   int main(int argc, const char* argv[]) {     scanf( %d%d , &n, &m);     for (int i = 0; i < n; i++) scanf( %d , x + i);     if (m == 1) {       puts( 1.00 );       return 0;     }     int cur = 0, pre = 1;     e[pre][0] = m - 1;     for (int i = 0; i < n; i++) {       cur = i % 2;       pre = 1 - cur;       sume[0] = e[pre][0];       for (int j = 1; j <= (i + 1) * m; j++) sume[j] = sume[j - 1] + e[pre][j];       for (int s = 0; s <= (i + 1) * m; s++) {         int l, r;         if (s >= 1) {           l = max(s - m, 0), r = s - 1;           if (l - 1 >= 0)             e[cur][s] = sume[r] - sume[l - 1];           else             e[cur][s] = sume[r];           if (l <= s - x[i] && s - x[i] <= r) e[cur][s] -= e[pre][s - x[i]];           e[cur][s] /= (double)(m - 1.0);         } else           e[cur][s] = 0;       }     }     int sum = 0;     double ans = 0;     for (int i = 0; i < n; i++) sum += x[i];     for (int i = 0; i < sum; i++) ans += e[cur][i];     printf( %.9lf n , ans + 1.0);     return 0;   }   