CSG1133 : Kick the ball!
Kick the ball!
题意:
给出每队的点球得分概率,求得分为a-b的概率
分析:
dfs搜每一种结果
实现:
bool check(int a, int b, int t)
{
if (a - b - (t + 1) / 2 > 0)
return true;
if (b - a - t / 2 > 0)
return true;
return false;
}
void dfs(int a, int b, int k, double tmp)
{
if (k == 10)
{
if (resa == a && resb == b)
{
res += tmp;
}
return;
}
if (check(a, b, 10 - k))
{
dfs(a, b, k + 1, tmp);
return;
}
if (k & 1)
{
dfs(a, b + 1, k + 1, tmp * p[k]);
dfs(a, b, k + 1, tmp * (1 - p[k]));
}
else
{
dfs(a + 1, b, k + 1, tmp * p[k]);
dfs(a, b, k + 1, tmp * (1 - p[k]));
}
}
void solve()
{
res = 0;
scanf("%lld-%lld", &resa, &resb);
dfs(0, 0, 0, 1.0);
printf("Case %lld: %.2lf%%\n", idx++, res * 100);
}
signed main()
{
while (~scanf("%lf %lf %lf %lf %lf %lf %lf %lf %lf %lf", &p[0], &p[2], &p[4], &p[6], &p[8], &p[1], &p[3], &p[5], &p[7], &p[9]))
solve();
return 0;
}