|
|
Nice proof,thanks. I will not forget this problem. I was on the right track, and needed about 3 more minutes for the right solution, but ran out of time. I did a different rationale, using gauss summation, combinations and recursion. This passed the system test (In the practice room).
double Prob(int M)
{
if (!M)
return 1;
if (M % 2)
return 0;
return (M - 1.0L) / (M + 1.0L) * IT (M - 2);
}
double
MonstersAndBunnies::survivalProbability(int M, int B)
{
return Prob(M);
}
The first factor in the return statement is the simplification of: ((M - 1 ) * M / 2) / (M! / (2! * (M - 2)!) |