func_code_string: #include <bits/stdc++.h>   using namespace ::std;   const long double PI = acos(-1);   const long long MOD = 1000000000 + 7;   long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }   long long add(long long a, long long b, long long m = MOD) {     return (a % m + b % m + 2 * m) % m;   }   long long mul(long long a, long long b, long long m = MOD) {     return ((a % m + m) * (b % m + m)) % m;   }   long long pow_mod(long long a, long long b, long long m = MOD) {     long long res = 1LL;     a = a % m;     while (b) {       if (b & 1) res = mul(res, a, m);       b >>= 1;       a = mul(a, a, m);     }     return res;   }   long long fastexp(long long a, long long b) {     long long res = 1LL;     while (b) {       if (b & 1) res = res * a;       b >>= 1;       a *= a;     }     return res;   }   int gcdExtendido(int a, int b, int *x, int *y) {     if (a == 0) {       *x = 0;       *y = 1;       return b;     }     int x1, y1;     int gcd = gcdExtendido(b % a, a, &x1, &y1);     *x = y1 - (b / a) * x1;     *y = x1;     return gcd;   }   int modInverso(int a, int m) {     int x, y;     int g = gcdExtendido(a, m, &x, &y);     if (g != 1)       return -1;     else       return (x % m + m) % m;   }   const int MAX = 1000000 + 5;   const int N = 100 + 5;   int n, m;   int v[N];   long double memo[2][MAX];   int main() {     scanf( %d %d , &(n), &(m));     int S = 0;     for (int i = 1; i <= n; i++) {       scanf( %d , &(v[i]));       S += v[i];     }     long double ans = 0.0;     if (m > 1) {       memo[0][0] = m - 1;       for (int i = 0; i < n; i++) {         int next = (i + 1) & 1;         int act = i & 1;         for (int j = 1; j <= n * m; j++) {           memo[act][j] += memo[act][j - 1];         }         for (int j = 0; j <= n * m; j++) {           memo[next][j] = 0.0;         }         int next_chosen = v[i + 1];         for (int j = 0; j <= i * m; j++) {           memo[next][j + 1] += memo[act][j] / (m - 1);           memo[next][j + m + 1] -= memo[act][j] / (m - 1);           memo[next][j + next_chosen] -= memo[act][j] / (m - 1);           memo[next][j + next_chosen + 1] += memo[act][j] / (m - 1);         }       }       for (int j = 1; j <= n * m; j++) {         memo[n & 1][j] += memo[n & 1][j - 1];       }       for (int j = 0; j < S; j++) {         ans += memo[n & 1][j];       }     }     ans += 1.0;     printf( %.16Lf n , ans);     return 0;   }   