标签:
1 #include<iostream> 2 #include<cstdio> 3 #include<cstring> 4 using namespace std; 5 #define N 106 6 int L; 7 int n,c,t; 8 int VR,VT1,VT2; 9 int p[N]; 10 double dp[N]; 11 12 int main() 13 { 14 while(scanf("%d",&L)==1){ 15 scanf("%d%d%d%d%d%d",&n,&c,&t,&VR,&VT1,&VT2); 16 for(int i=1;i<=n;i++){ 17 scanf("%d",&p[i]); 18 } 19 double time_rbt=L*1.0/VR;//兔子的时间,不变 20 21 //printf("%d\n",time_rbt); 22 23 p[0]=0; 24 p[n+1]=L; 25 26 dp[0]=0; 27 28 for(int i=1;i<=n+1;i++){ 29 double minnn=10000000; 30 for(int j=0;j<i;j++){ 31 double tmp; 32 int len=p[i]-p[j]; 33 if(c>=len){ 34 tmp=len*1.0/VT1; 35 }else{ 36 tmp=c*1.0/VT1+(len-c)*1.0/VT2; 37 } 38 if(j!=0){ 39 tmp=tmp+t; 40 } 41 if(minnn>tmp+dp[j]){ 42 minnn=tmp+dp[j]; 43 } 44 } 45 dp[i]=minnn; 46 } 47 if(dp[n+1]>time_rbt){ 48 printf("Good job,rabbit!\n"); 49 continue; 50 } 51 printf("What a pity rabbit!\n"); 52 } 53 return 0; 54 }
标签:
原文地址:http://www.cnblogs.com/UniqueColor/p/5140971.html