标签:des style blog http io color os ar java
Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 11559 Accepted Submission(s): 4348
多阶段决策、、、DP、、、
#include <iostream> #include <cstdio> #include <algorithm> using namespace std; #define min(a,b) ((a)<(b)?(a):(b)) #define INF 0x7ffffff #define N 110 int l,n,c,t; int vr,vg,vb; double dp[N]; int p[N]; int main() { int i,j; while(scanf("%d",&l)!=EOF) { scanf("%d%d%d",&n,&c,&t); scanf("%d%d%d",&vr,&vg,&vb); for(i=1;i<=n;i++) { scanf("%d",&p[i]); } for(i=1;i<=n+1;i++) { dp[i]=INF; } dp[0]=0; p[0]=0; p[n+1]=l; for(i=1;i<=n+1;i++) { for(j=0;j<i;j++) { int len=p[i]-p[j]; double time=0; if(j) time+=t; if(len<=c) time+=len*1.0/vg; else time+=c*1.0/vg+(len-c)*1.0/vb; time+=dp[j]; dp[i]=min(dp[i],time); } } cout<<dp[n+1]<<‘ ‘<<l*1.0/vr<<endl; if(dp[n+1]>l*1.0/vr) cout<<"Good job,rabbit!\n"; else cout<<"What a pity rabbit!\n"; } return 0; }
标签:des style blog http io color os ar java
原文地址:http://www.cnblogs.com/hate13/p/4055318.html