#include #include #include using namespace std; typedef long long Int; struct change { double t,v; double y; }; change changes[100001]; double gravity=-9.81; Int n; bool SortChanges(change a,change b) { if (a.t=0.0) return true; else return false; } Int DoubleSearch(double timer) { Int l,r,mid; Int ans=0; l=1; r=n; while(l<=r) { mid=(l+r)/2; if (LessOrEqual(changes[mid].t,timer)) { ans=mid; l=mid+1; } else { r=mid-1; } } return ans; } int main() { freopen("ball.in","r",stdin); freopen("ball.out","w",stdout); Int i; Int q; double a; double s; double thetime; double vel; Int index; double ansy; double ansx; scanf("%I64d",&n); for (i=1;i<=n;i++) { scanf("%lf %lf",&changes[i].t,&changes[i].v); } sort(changes+1,changes+1+n,SortChanges); thetime=changes[1].t; changes[1].y=(gravity*thetime*thetime)/2.0; for (i=2;i<=n;i++) { thetime=changes[i].t-changes[i-1].t; s=changes[i-1].y; vel=changes[i-1].v; changes[i].y=(gravity*thetime*thetime)/2.0 + vel*thetime + s; } scanf("%I64d",&q); for (i=1;i<=q;i++) { scanf("%lf",&a); ansx=5.0*a; index=DoubleSearch(a); if (index==0) { thetime=a; ansy=(gravity*thetime*thetime)/2.0; } else { thetime=a-changes[index].t; s=changes[index].y; vel=changes[index].v; ansy=(gravity*thetime*thetime)/2.0 + vel*thetime + s; } printf("%4.3f %4.3f\n",ansx,ansy); } return 0; }