hdu 2059 龟兔赛跑

#include 
#include 
#include 
#include 
using namespace std;

#define INF 0xfffffff
#define MAXN 110

double dp[MAXN], dis[MAXN];

int main ()
{
    //freopen ("in.txt", "r", stdin);
    int N;
    double L, C, T, VR, VT1, VT2;
    while (cin >> L)
    {
        cin >> N >> C >> T >> VR >> VT1 >> VT2;
        dis[0] = dp[0] = 0, dis[N+1] = L;
        for (int i=1; i<=N; i++)
            cin >> dis[i];
        for (int i=1; i<=N+1; i++)
        {
            dp[i] = INF;
            for (int j=0; j C)
                    TimeT = C / VT1 + (DisT - C) / VT2;
                else
                    TimeT = DisT / VT1;
                if (j) TimeT += T;
                dp[i] = min (dp[i], dp[j] + TimeT);
            }
        }
        if (dp[N+1] < L / VR)
            cout << "What a pity rabbit!" << endl;
        else
            cout << "Good job,rabbit!" << endl;
    }
    return 0;
}

你可能感兴趣的:(动态规划,算法,dp,动态规划)