标签:tac turn using double 记录 can 代码 lin name
出门右转https://www.lydsy.com/JudgeOnline/problem.php?id=4832
容易知道血量相同的奴隶主性质相同。
所以记忆化搜索就好了!
#include <bits/stdc++.h> using namespace std; typedef long double ld; ld dp[55][8][8][8]; ld dfs(int k,int a,int b,int c) { if (k == 0) return 0; if (dp[k][a][b][c]) return dp[k][a][b][c]; // attack , main ld ret = dfs(k-1, a, b, c) + 1; // attack a if (a) ret += dfs(k-1, a-1, b, c) * a; // attack b if (b) ret += dfs(k-1, a+1, b-1, min(7-a-b, c+1)) * b; // attack c if (c) ret += dfs(k-1, a, b+1, min(6-a-b, c)) * c; return dp[k][a][b][c] = ret / (1 + a + b + c); } int main() { int T; scanf("%d", &T); while (T--) { int k, a, b, c; scanf("%d%d%d%d", &k, &a, &b, &c); if (!dfs(k, a, b, c)) printf("0.00\n"); else printf("%.2Lf\n", dfs(k, a, b, c)); } return 0; }
标签:tac turn using double 记录 can 代码 lin name
原文地址:https://www.cnblogs.com/mchmch/p/bzoj-4832.html