# [BZOJ4832][Lydsy1704月赛]抵制克苏恩

## Description

。现在小Q同学会给出克苏恩的攻击力是 K ，表示克苏恩会攻击 K 次，每次会从对方场上的英雄和随从中随机选

；如果克苏恩攻击了你的英雄，你的英雄会记录受到 1 点伤害。你应该注意到了，每当克苏恩进行一次攻击，你

1
1 1 1 1

## Sample Output

0.25

#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
#define gc getchar()
int res=0;char ch=gc;
while(!isdigit(ch))ch=gc;
while(isdigit(ch)){res=(res<<3)+(res<<1)+(ch^48);ch=gc;}
return res;
}
#undef gc
int T, K, a, b, c;
double f[55][10][10][10];
double ans;

int main()
{
while(T--) {
memset(f, 0, sizeof f);
f[0][a][b][c] = 1.0;
ans = 0.0;
for (int i = 0 ; i < K ; i ++) {
for (int j = 0 ; j <= 7 ; j ++) {
for (int k = 0 ; k <= 7 - j ; k ++) {
for (int p = 0 ; p <= 7 - j - k ; p ++) {
double tmp = 1.0 / (j + k + p + 1.0);
f[i+1][j][k][p] += f[i][j][k][p] * tmp;
ans += f[i][j][k][p] * tmp;
if (j - 1 >= 0)
f[i+1][j-1][k][p] += f[i][j][k][p] * tmp * j;
if (k - 1 >= 0) {
if (j + k + p < 7) f[i+1][j+1][k-1][p+1] += f[i][j][k][p] * tmp * k;
else f[i+1][j+1][k-1][p] += f[i][j][k][p] * tmp * k;
}
if (p - 1 >= 0) {
if (j + k + p < 7) f[i+1][j][k+1][p] += f[i][j][k][p] * tmp * p;
else f[i+1][j][k+1][p-1] += f[i][j][k][p] * tmp * p;
}
}
}
}
}
printf("%.2lf\n", ans);
}
return 0;
}

$\sum_{age=16}^{18} hardworking = success$

18age=16hardworking=success
posted @ 2018-07-30 15:49  zZhBr  阅读(142)  评论(0编辑  收藏  举报