其他分享
首页 > 其他分享> > CF1245E:Hyakugoku and Ladders

CF1245E:Hyakugoku and Ladders

作者:互联网

CF1245E:Hyakugoku and Ladders

题意描述:

思路:

#include<bits/stdc++.h>
using namespace std;
const int maxn = 15;
int g[maxn][maxn];
int nex[maxn][maxn];
int a[maxn*maxn];
double f[maxn*maxn];
int main()
{
    for(int i = 1; i <= 10; i++)
        for(int j = 1; j <= 10; j++)
            nex[i][j] = (i-1)*10 + (i&1 ? j : 11-j);

    for(int i = 1; i <= 10; i++)
        for(int j = 1, x; j <= 10; j++){
            scanf("%d", &x);
            a[nex[i][j]] = nex[i-x][j];
        }

    f[1] = 0;
    double sum = 0;
    for(int i = 2; i <= 6; i++)
        f[i] = (sum+6) / (i-1), sum += f[i];

    for(int i = 7; i <= 100; i++)
    {
        sum = 0;
        for(int r = 1; r <= 6; r++)
            sum = sum + min(f[i-r], f[a[i-r]]);
        f[i] = sum / 6.0 + 1;
    }

    printf("%.10f", f[100]);
    return 0;
}

标签:Hyakugoku,int,Ladders,maxn,CF1245E,回合,梯子
来源: https://www.cnblogs.com/zxytxdy/p/11823902.html