Hdu2059 龟兔赛跑(动态规划)

 

 

import java.util.Scanner;

public class HDU2059 {
	static double time=0.0;
	static double min(double a,double b) {
		if(a>b)return b;
		else return a;
	}
	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		while(in.hasNext()) {
			int L=in.nextInt();
			int N=in.nextInt();
			int C=in.nextInt();
			int T=in.nextInt();
			int VR=in.nextInt();
			int VT1=in.nextInt();
			int VT2=in.nextInt();
			int[]p=new int[N+2];
			double[]dp=new double[N+2];
			dp[0]=0;
			for(int i=1;iC) {
						time=1.0*C/VT1+(p[i]-p[j]-C)*1.0/VT2;
					}
					else {
						time=1.0*(p[i]-p[j])/VT1;
					}
					if(j>0)time=time+T;
					time=time+dp[j];
					dp[i]=min(time,dp[i]);
				}
			}
			double time1=1.0*L/VR;
			if(dp[N+1]

 

你可能感兴趣的:(Hdu2059 龟兔赛跑(动态规划))