zoukankan      html  css  js  c++  java
  • BZOJ4832 抵制克苏恩(概率期望+动态规划)

      注意到A+B+C很小,容易想到设f[i][A][B][C]为第i次攻击后有A个血量为1、B个血量为2、C个血量为3的期望伤害,倒推暴力转移即可。

    #include<iostream> 
    #include<cstdio>
    #include<cmath>
    #include<cstdlib>
    #include<cstring>
    #include<algorithm>
    using namespace std;
    #define ll long long
    char getc(){char c=getchar();while ((c<'A'||c>'Z')&&(c<'a'||c>'z')&&(c<'0'||c>'9')) c=getchar();return c;}
    int gcd(int n,int m){return m==0?n:gcd(m,n%m);}
    int read()
    {
        int x=0,f=1;char c=getchar();
        while (c<'0'||c>'9') {if (c=='-') f=-1;c=getchar();}
        while (c>='0'&&c<='9') x=(x<<1)+(x<<3)+(c^48),c=getchar();
        return x*f;
    }
    double f[59][8][8][8];
    int T,n,a,b,c;
    int main()
    {
    #ifndef ONLINE_JUDGE
        freopen("bzoj4832.in","r",stdin);
        freopen("bzoj4832.out","w",stdout);
        const char LL[]="%I64d
    ";
    #else
        const char LL[]="%lld
    ";
    #endif
        T=read();
        for (int i=1;i<=50;i++)
            for (int x=0;x<=7;x++)
                for (int y=0;y<=7-x;y++)
                    for (int z=0;z<=7-x-y;z++)
                    {
                        f[i][x][y][z]=f[i-1][x][y][z]+1;
                        if (x) f[i][x][y][z]+=f[i-1][x-1][y][z]*x;
                        if (y) f[i][x][y][z]+=f[i-1][x+1][y-1][z+(x+y+z<7)]*y;
                        if (z) f[i][x][y][z]+=f[i-1][x][y+1][z-1+(x+y+z<7)]*z;
                        f[i][x][y][z]/=(x+y+z+1);
                    }
        while (T--)
        {
            n=read(),a=read(),b=read(),c=read();
            printf("%.2lf
    ",f[n][a][b][c]);
        }
        return 0;
    }
  • 相关阅读:
    csps模拟测试70
    模拟测试66反思
    csps63总结
    csps60爆零记
    csps模拟测试57
    模拟测试52,53反思
    LOJ2542「PKUWC2018」随机游走
    LOJ6300 BZOJ5283 [CodePlus 2018 3 月赛]博弈论与概率统计
    2019暑假集训
    省队二轮集训笔记
  • 原文地址:https://www.cnblogs.com/Gloid/p/10010055.html
Copyright © 2011-2022 走看看