#include #include #include using namespace std; typedef vector VI; typedef long double LD; typedef long long int LL; typedef vector VLL; typedef vector VVLL; LD ComputeProbability(const VI &sides, const int x) { VVLL sum(2, VLL(20 * sides.size() + 1)); sum[0][0] = 1; if (x < 0) return 0; if (x >= sum[0].size()) return 0; // consider one die at a time LL den = 1; for (size_t i = 0; i < sides.size(); i++) { fill(sum[(i+1)%2].begin(), sum[(i+1)%2].end(), 0); den *= sides[i]; // consider all possible rolls and new sums for (int roll = 1; roll <= sides[i]; roll++) { for (size_t j = roll; j < sum[0].size(); j++) { sum[(i+1)%2][j] += sum[i%2][j-roll]; } } } // cannot overflow (den <= 20^13) return LD(sum[sides.size()%2][x]) / LD(den); } int main() { while (1) { int d; cin >> d; if (d == 0) break; VI sides; for (int i = 0; i < d; i++) { string s; cin >> s; sides.push_back(atoi(s.substr(1).c_str())); } int x; cin >> x; printf("%.5Lf\n", ComputeProbability(sides, x)); } return 0; }