func_code_string: #include <bits/stdc++.h>   using namespace std;   const int maxn = 103, maxm = 1003;   int m, n, ar[maxn];   double dp[maxn * maxm], pre[maxn * maxm];   int main() {     scanf( %d%d , &n, &m);     if (m == 1) {       printf( 1 );       return 0;     }     int sum = 0;     for (int i = 1; i <= n; i++) scanf( %d , &ar[i]), sum += ar[i];     dp[0] = 1;     for (int i = 1; i <= n; i++) {       pre[0] = dp[0];       for (int j = 1; j <= i * m; j++) pre[j] = pre[j - 1] + dp[j];       for (int j = i * m; j; j--) {         dp[j] = pre[j - 1];         if (j - m - 1 >= 0) dp[j] -= pre[j - m - 1];         if (j - ar[i] >= 0) dp[j] -= dp[j - ar[i]];         dp[j] /= m - 1;       }       dp[0] = 0;     }     double ans = 0;     for (int i = 0; i < sum; i++) ans += dp[i];     printf( %.10lf n , 1 + ans * (m - 1));     return 0;   }   