func_code_string: #include <bits/stdc++.h>   using namespace std;   int n, m;   int R[101];   double dp[100100], sum[100100];   int main() {     scanf( %d%d , &n, &m);     if (m == 1) {       puts( 1 );       return 0;     }     int score = 0;     dp[0] = 1;     double f = 1. / (m - 1);     for (int i = 0; i < n; ++i) {       scanf( %d , R + i);       score += R[i];     }     for (int i = 0; i < n; ++i) {       int r = R[i];       sum[0] = dp[0];       for (int j = 1; j <= min(score - 1, (i + 1) * m); ++j) {         sum[j] = sum[j - 1] + dp[j];       }       for (int j = min(score - 1, (i + 1) * m); j > 0; --j) {         dp[j] = sum[j - 1];         if (j - m - 1 >= 0) dp[j] -= sum[j - m - 1];         if (j - r >= 0) dp[j] -= dp[j - r];         dp[j] *= f;       }       dp[0] = 0;     }     double res = 1;     for (int i = 0; i < score; ++i) {       res += dp[i] * (m - 1);     }     printf( %.15lf n , res);     return 0;   }   