func_code_string: #include <bits/stdc++.h>   using namespace std;   const int N = 110;   const int M = 1010;   double f[N][M * N], sum[N * M];   int a[N], n, m, s;   int main() {     scanf( %d%d , &n, &m);     for (int i = 1; i <= n; i++) {       scanf( %d , a + i);       s += a[i];     }     f[0][0] = 1;     sum[0] = 1.0;     for (int j = 1; j < s; j++) sum[j] = sum[j - 1] + f[0][j];     for (int i = 1; i <= n; i++) {       for (int j = i; j < s; j++) {         int l = min(m, j - i + 1);         int r = max(-1, j - l - 1);         double tmp = sum[j - 1] - ((r == -1) ? 0 : sum[r]);         if (l < a[i])           f[i][j] = tmp / (m - 1);         else           f[i][j] = (tmp - f[i - 1][j - a[i]]) / (m - 1);       }       sum[0] = 0;       for (int j = 1; j < s; j++) {         sum[j] = sum[j - 1] + f[i][j];       }     }     double ans = 0;     for (int i = n; i < s; i++) {       ans += f[n][i];     }     printf( %.10f n , 1 + ans * (m - 1));     return 0;   }   