【BZOJ】【P2328】【HNOI2011】【赛车游戏】

传送门:http://www.lydsy.com/JudgeOnline/problem.php?id=2328

题解传送门:http://www.cnblogs.com/Randolph87/p/3667963.html

Code:

#include
using namespace std;
const int maxn=1e4+10;
const double eps=1e-7;
int T,n;
double vmax,a,b,f;
int dcmp(double x){
	if(fabs(x)0?1:-1;
}
struct road{
	double len,s,v;
	bool operator<(const road &r)const{
		return v=0){
					f-=(r[i+1].v-r[i].v)*sum*a;
					r[i].v=r[i+1].v;
				}else{
					r[i].v+=f/(sum*a);
					break;
				}
			}
		}
		for(int j=i-1;j>=1;j--)
			r[j].v=r[j+1].v;
		if(dcmp(r[1].v)==0){
			puts("IMPOSSIBLE");
			continue;
		}
		double ans=0;
		for(int i=1;i<=n;i++)
		ans+=r[i].len/r[i].v;
		printf("%.5lf\n",ans);
	}	
	return 0;
}


你可能感兴趣的:(OI)