http://community.topcoder.com/stat?c=problem_statement&pm=11473&rd=14543
简单的概率题。那道题想了想就出来了。每一轮中所有硬币都有相同的概率变化成另一面。
public class CoinReversing
{
public double expectedHeads(int N, int[] a)
{
double heads = N;
double tails = 0; for (int i = 0; i < a.length; i++)
{
heads = ((N-a[i])*heads + a[i]*tails) / N;
tails = N - heads;
}
return heads;
}
}