该问题和xi,di均无关,碰撞只会使得速度反向,大小不会变。因此只要计算速度。
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<iostream>
using namespace std;
typedef long long LL;
const double pi=acos(-1.0),eps=1e-;
void File()
{
freopen("D:\\in.txt","r",stdin);
freopen("D:\\out.txt","w",stdout);
}
inline int read()
{
char c = getchar(); while(!isdigit(c)) c = getchar(); int x = ;
while(isdigit(c)) { x = x * + c - ''; c = getchar(); }
return x;
} const int maxn=;
int T,n;
double C,v0[maxn]; int main()
{
scanf("%d",&T); while(T--)
{
scanf("%d%lf",&n,&C);
for(int i=;i<=n;i++)
{
scanf("%lf",&v0[i]);
int xi,di; scanf("%d%d",&xi,&di);
}
sort(v0+,v0+n+);
int q; scanf("%d",&q);
for(int i=;i<=q;i++)
{
int t,k; scanf("%d%d",&t,&k);
printf("%.3lf\n",sqrt(2.0*C*t+v0[k]*v0[k]));
}
}
return ;
}