const double EPS = 1e-8; using namespace std; int sum; double rd, win; void dfs(int a, int lev, double p) { if (p < EPS) return; if (a == 0) { rd += lev * p; return; } else if (a == sum) { rd += lev * p; win += p; return; } int Min = min(a, sum - a); dfs(a - Min, lev + 1, p * 0.5); dfs(a + Min, lev + 1, p * 0.5); } int main() { int T, a, b; RI(T); FE(kase, 1, T) { RII(a, b); rd = win = 0; sum = a + b; dfs(a, 0, 1); printf("Case %d: %.6f %.6f\n", kase, rd, win); } return 0; }
Poker End Games,布布扣,bubuko.com
原文地址:http://blog.csdn.net/wty__/article/details/25747227