func_code_string: #include <bits/stdc++.h>   using namespace std;   long double dp[1010000][3];   int n, m;   int ranks[1245];   int Prank;   int main() {     cout << fixed << setprecision(12);     cin >> n >> m;     if (m == 1) {       cout <<  1 n ;       return 0;     }     for (int i = 1; i <= (n); ++i) {       cin >> ranks[i];       Prank += ranks[i];     }     for (int i = 1; i <= (Prank); ++i) dp[i][0] = dp[i][1] = dp[i][2] = 0;     for (int i = 1; i <= (m); ++i) {       if (i == ranks[1]) continue;       dp[i][0] = 1.0;     }     for (int i = 2; i <= (n); ++i) {       for (int j = 1; j <= (Prank); ++j) {         dp[j][1] = dp[j][0] + dp[j - 1][1];       }       for (int j = Prank; j >= (1); --j) {         dp[j][2] = dp[j - 1][1];         if (j - m > 0) dp[j][2] -= dp[j - m - 1][1];         if (j - ranks[i] > 0) dp[j][2] -= dp[j - ranks[i]][0];       }       for (int j = 1; j <= (Prank); ++j)         dp[j][0] = dp[j][2] / ((long double)(m - 1));     }     long double sum = 0;     for (int i = 1; i <= (Prank - 1); ++i) {       sum += dp[i][0];     }     sum += 1;     cout << sum << endl;   }   