这个版本带克苏恩怕是活不到10费啊
#include <cstdio>
#include <cstring>
using namespace std;
inline int read(void)
{
int a=0;static char c;
while((c=getchar())<'0'||c>'9');
while(c>='0'&&c<='9')
a=a*10+c-'0',c=getchar();
return a;
}
int T,n,x,y,z;
double dp[2][51][8][8][8],ans;
int main(void)
{
register int i,j,l,k;
T=read();
while(T--)
{
ans=0;
n=read(),memset(dp,0,sizeof(dp));
dp[0][0][x=read()][y=read()][z=read()]=1,dp[1][0][x][y][z]=0;
for (i=0;i<n;++i)
for (j=0;j<=7;++j)
for (k=0;k<=7;++k)
for (l=0;l<=7;++l)
if(dp[0][i][j][k][l]>0)
{
if(i+1==n)
{
ans+=dp[1][i][j][k][l]*(1.0/(j+k+l+1))+dp[0][i][j][k][l]*(1.0/(j+k+l+1));
if(j)
ans+=dp[1][i][j][k][l]*j*(1.0/(j+k+l+1));
if(k)
{
if(j+k+l<7)
ans+=dp[1][i][j][k][l]*k*(1.0/(j+k+l+1));
if(j+k+l==7)
ans+=dp[1][i][j][k][l]*k*(1.0/(j+k+l+1));
}
if(l)
{
if(j+k+l<7)
ans+=dp[1][i][j][k][l]*l*(1.0/(j+k+l+1));
if(j+k+l==7)
ans+=dp[1][i][j][k][l]*l*(1.0/(j+k+l+1));
}
}
else
{
dp[0][i+1][j][k][l]+=dp[0][i][j][k][l]*(1.0/(j+k+l+1));
dp[1][i+1][j][k][l]+=dp[1][i][j][k][l]*(1.0/(j+k+l+1))+dp[0][i][j][k][l]*(1.0/(j+k+l+1));
if(j)
dp[0][i+1][j-1][k][l]+=dp[0][i][j][k][l]*j*(1.0/(j+k+l+1)),
dp[1][i+1][j-1][k][l]+=dp[1][i][j][k][l]*j*(1.0/(j+k+l+1));
if(k)
{
if(j+k+l<7)
dp[0][i+1][j+1][k-1][l+1]+=dp[0][i][j][k][l]*k*(1.0/(j+k+l+1)),
dp[1][i+1][j+1][k-1][l+1]+=dp[1][i][j][k][l]*k*(1.0/(j+k+l+1));
if(j+k+l==7)
dp[0][i+1][j+1][k-1][l]+=dp[0][i][j][k][l]*k*(1.0/(j+k+l+1)),
dp[1][i+1][j+1][k-1][l]+=dp[1][i][j][k][l]*k*(1.0/(j+k+l+1));
}
if(l)
{
if(j+k+l<7)
dp[0][i+1][j][k+1][l]+=dp[0][i][j][k][l]*l*(1.0/(j+k+l+1)),
dp[1][i+1][j][k+1][l]+=dp[1][i][j][k][l]*l*(1.0/(j+k+l+1));
if(j+k+l==7)
dp[0][i+1][j][k+1][l-1]+=dp[0][i][j][k][l]*l*(1.0/(j+k+l+1)),
dp[1][i+1][j][k+1][l-1]+=dp[1][i][j][k][l]*l*(1.0/(j+k+l+1));
}
}
}
printf("%.2lf\n",ans);
}
return 0;
}