func_code_string: #include <bits/stdc++.h>   using namespace std;   long double mem[50 + 5][50 + 5][50 + 5];   long double fact[55];   vector<int> num;   int n, p, L;   long double dp(int sum, int idx, int cnt, int last) {     if (sum > p || cnt > L) {       return 0;     }     if (idx == n) {       return (sum + num[last] > p && cnt + 1 == L);     }     long double &ret = mem[sum][idx][cnt];     if (ret == ret) {       return ret;     }     ret = 0;     if (idx != last) ret += dp(sum + num[idx], idx + 1, cnt + 1, last);     ret += dp(sum, idx + 1, cnt, last);     return ret;   }   void solve() {     long double ans = 0;     fact[0] = 1;     for (int i = 1; i <= 50; i++) {       fact[i] = fact[i - 1] * i;     }     for (int i = 2; i <= n; i++) {       for (int j = 0; j < n; j++) {         memset(mem, -1, sizeof(mem));         L = i;         long double ret = dp(0, 0, 0, j);         if (ret) ans += (fact[i - 1] * fact[n - i] / fact[n] * ret * (i - 1));       }     }     int sum = 0;     for (int i = 0; i < n; i++) {       sum += num[i];     }     if (ans == 0 && sum <= p) ans = n;     cout << ans << endl;   }   int main() {     int a;     cin >> n;     for (int i = 0; i < n; i++) {       cin >> a;       num.push_back(a);     }     cin >> p;     solve();   }   