题目地址:http://codeforces.com/gym/100531/attachments
思路:风速与飞机速度单独考虑,先算出起点与终点x与y轴的位移。仅考虑风速时,算出风的作用使飞机移动的距离,如果加上最大速度仍不能使飞机到达,则无解。否则,取平均速速作为飞机的速度,按时间模拟即可。
#include<cstdio>
#include<cmath>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
const int maxn=10000+50;
int n,k;
double sx,sy,fx,fy,vm;
double t[maxn],wx[maxn],wy[maxn];
int main()
{
freopen("joy.in","r",stdin);
freopen("joy.out","w",stdout);
scanf("%lf%lf%lf%lf",&sx,&sy,&fx,&fy);
scanf("%d%d%lf",&n,&k,&vm);
for(int i=0; i<n; i++)
scanf("%lf%lf%lf",&t[i],&wx[i],&wy[i]);
t[n]=k;
double dx=fx-sx,dy=fy-sy;
//cout<<dx<<" "<<dy<<endl;
for(int i=0; i<n; i++)
{
dx-=(wx[i]*(t[i+1]-t[i]));
dy-=(wy[i]*(t[i+1]-t[i]));
//cout<<dx<<" "<<dy<<endl;
}
if(sqrt(dx*dx+dy*dy)>vm*k) printf("No\n");
else
{
printf("Yes\n");
int pos=0;
double ansx=sx,ansy=sy;
double avevx=dx/k,avevy=dy/k;
//cout<<avevx<<" "<<avevy<<endl;
for(int i=1; i<=k; i++)
{
if(t[pos+1]<i) pos++;
ansx+=(wx[pos]+avevx);
ansy+=( wy[pos]+avevy);
printf("%f %f\n",ansx,ansy);
}
}
return 0;
}