#include #include #include #include #include using namespace std; const int MAX_HEALTH = 6; const int MAX_MINIONS = 5; const int HEALTH_SPACE = MAX_HEALTH * 2 + 1; typedef long long ll; ll encode(vector &state) { ll code = 0; for(int i=0;i decode(ll code) { int n = code % (MAX_MINIONS * 2 + 1); code /= (MAX_MINIONS * 2 + 1); vector a(n); for(int i=0;i state) { cout << '['; for(int i=0;i 0) cout << ", "; cout << state[i]; } cout << "]" << endl; } int main() { int m, n, expl; cin >> m >> n >> expl; vector start(m+n); int tot = 0; for(int i=0;i> start[i]; tot += start[i]; } for(int i=0;i> start[i+m]; tot += start[i+m]; start[i+m] = -start[i+m]; } if (expl >= tot) { cout << 1.0 << endl; return 0; } sort(start.begin(), start.end()); map q; q[encode(start)] = 1.0; int no_iter = 0; for(int turns = 0; turns < expl; turns++) { map nq; for(map::iterator qi = q.begin(); qi != q.end(); qi++) { vector state = decode(qi->first); for(int i=0;i copy = vector(state.begin(), state.end()); if (copy[i] < 0) { copy[i]++; } else { copy[i]--; } if (copy[i] == 0) { copy.erase(copy.begin()+i, copy.begin()+i+1); } else { sort(copy.begin(), copy.end()); } ll new_code = encode(copy); nq[new_code] += qi->second / state.size(); } } q = nq; } double tot_prob = 0.0; for(map::iterator qi = q.begin(); qi != q.end(); qi++) { if (decode(qi->first)[0] > 0) { tot_prob += qi->second; } } cout << fixed << setprecision(10) << tot_prob << endl; //cout << no_iter << endl; return 0; }