【题意】:略
【题解】:期望dp,如果不考虑joker就变得非常简单。但现在joker可以变成任意花色,所以如果当前翻到joker需要枚举这个joker变成什么花色,取最小的期望即可。
【代码】:
1 #include "iostream"
2 #include "cstdio"
3 #include "cstring"
4 #include "algorithm"
5 #include "vector"
6 #include "queue"
7 #include "cmath"
8 #include "string"
9 #include "cctype"
10 #include "map"
11 #include "iomanip"
12 using namespace std;
13 #define pb push_back
14 #define mp make_pair
15 #define fi first
16 #define se second
17 #define lc(x) (x << 1)
18 #define rc(x) (x << 1 | 1)
19 #define lowbit(x) (x & (-x))
20 #define ll long long
21 int aa, bb, cc, dd;
22 double dp[16][16][16][16][5][5];
23 bool visit[16][16][16][16][5][5];
24
25 double dfs(int a, int b, int c, int d, int big, int small) {
26 double &tmp = dp[a][b][c][d][big][small];
27 if(visit[a][b][c][d][big][small]) return tmp;
28 visit[a][b][c][d][big][small] = true;
29 int now[] = {a, b, c, d};
30 if(big != 4) now[big]++;
31 if(small != 4) now[small]++;
32 if(now[0] >= aa && now[1] >= bb && now[2] >= cc && now[3] >= dd) return tmp = 0.0;
33 tmp = 1.0;
34 double sum = now[0] + now[1] + now[2] + now[3];
35 if(a < 13) tmp += dfs(a + 1, b, c, d, big, small) * (13.0 - a) / (54.0 - sum);
36 if(b < 13) tmp += dfs(a, b + 1, c, d, big, small) * (13.0 - b) / (54.0 - sum);
37 if(c < 13) tmp += dfs(a, b, c + 1, d, big, small) * (13.0 - c) / (54.0 - sum);
38 if(d < 13) tmp += dfs(a, b, c, d + 1, big, small) * (13.0 - d) / (54.0 - sum);
39 if(big == 4) {
40 double tmp1 = 1e100;
41 tmp1 = min(tmp1, dfs(a, b, c, d, 0, small) / (54.0 - sum));
42 tmp1 = min(tmp1, dfs(a, b, c, d, 1, small) / (54.0 - sum));
43 tmp1 = min(tmp1, dfs(a, b, c, d, 2, small) / (54.0 - sum));
44 tmp1 = min(tmp1, dfs(a, b, c, d, 3, small) / (54.0 - sum));
45 tmp += tmp1;
46 }
47 if(small == 4) {
48 double tmp1 = 1e100;
49 tmp1 = min(tmp1, dfs(a, b, c, d, big, 0) / (54.0 - sum));
50 tmp1 = min(tmp1, dfs(a, b, c, d, big, 1) / (54.0 - sum));
51 tmp1 = min(tmp1, dfs(a, b, c, d, big, 2) / (54.0 - sum));
52 tmp1 = min(tmp1, dfs(a, b, c, d, big, 3) / (54.0 - sum));
53 tmp += tmp1;
54 }
55 return tmp;
56 }
57
58 int main() {
59 int T, Case = 1;
60 cin >> T;
61 while(T--) {
62 cin >> aa >> bb >> cc >> dd;
63 int cnt = 0;
64 cnt += max(aa - 13, 0);
65 cnt += max(bb - 13, 0);
66 cnt += max(cc - 13, 0);
67 cnt += max(dd - 13, 0);
68 printf("Case %d: ", Case++);
69 if(cnt > 2) printf("-1.000\n");
70 else {
71 memset(visit, false, sizeof(visit));
72 printf("%.3f\n", dfs(0, 0, 0, 0, 4, 4));
73 }
74 }
75 return 0;
76 }
77