题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2059
100 3 20 5 5 8 2 10 40 60 100 3 60 5 5 8 2 10 40 60
Good job,rabbit! What a pity rabbit!
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <string>
#include <cstdio>
#include <cmath>
using namespace std;
double dp[220];
double a[220];
int main()
{
        double l,c,t;
        int n;
        double vr,vt1,vt2;
        while(scanf("%lf",&l)!=EOF)
        {
            scanf("%d%lf%lf",&n,&c,&t);
            scanf("%lf%lf%lf",&vr,&vt1,&vt2);
            for(int i=1;i<=n;i++)scanf("%lf",&a[i]);
            //处理一下细节
            a[0]=0.0;
            dp[0]=0.0;
            a[n+1]=l;
            double len,temp,min;
            for(int i=1;i<=n+1;i++)
             {
              min=99999999.0;
              for(int j=0;j<i;j++)
              {
                len=a[i]-a[j];
                temp=len>c?(c/vt1+(len-c)/vt2):(len/vt1);
                if(j)              
                  temp+=t;   //这个地方在纸上画一画应该能想明白
                if(min>temp+dp[j])
                  min=temp+dp[j];
              }
              
              dp[i]=min;
             }
           printf("%s\n",dp[n+1]<l/vr?"What a pity rabbit!":"Good job,rabbit!");
        }
        return 0;
}
原文地址:http://blog.csdn.net/liusuangeng/article/details/38943205