#include<bits/stdc++.h>
#include<iostream>
#define db long double
usingnamespacestd;
structsd{db v,w,t;};
constintM=55;
intn;
db totw,le,ri,mid,u,t;
sd riv[M];
db sqr(db x){returnx*x;}
voidin()
{
scanf("%d%Lf%Lf",&n,&u,&t);
for(inti=1;i<=n;++i)
scanf("%Lf%Lf",&riv[i].w,&riv[i].v),totw+=riv[i].w,le=max(le,riv[i].v);
}
db check(db x)
{
db r=0,hh;
for(inti=1;i<=n;++i)
{
hh=(x-riv[i].v)*(x-riv[i].v);
riv[i].t=sqrt((hh*sqr(riv[i].w))/(hh*sqr(u)-sqr(u)*sqr(u)));
r+=riv[i].t;
}
returnr;
}
voidac()
{
le+=u;ri=1e12;
if(totw/u>t)printf("-1"),exit(0);
for(inti=1;i<=5000;++i)
{
mid=(le+ri)*0.5;
if(check(mid)>=t)le=mid;
elseri=mid;
}
check(le);
db toth=0;
for(inti=1;i<=n;++i)toth+=sqrt(sqr(u*riv[i].t)-sqr(riv[i].w))+riv[i].v*riv[i].t;
printf("%.3Lf\n",sqrt(sqr(totw)+sqr(toth)));
for(inti=1;i<=n;++i)printf("%.3Lf ",riv[i].t);
}
intmain()
{
in();ac();
return0;
}
全部评论
(5) 回帖