HDU 5826 physics
该问题和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-8; 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 = 0; while(isdigit(c)) { x = x * 10 + c - '0'; c = getchar(); } return x; } const int maxn=100010; int T,n; double C,v0[maxn]; int main() { scanf("%d",&T); while(T--) { scanf("%d%lf",&n,&C); for(int i=1;i<=n;i++) { scanf("%lf",&v0[i]); int xi,di; scanf("%d%d",&xi,&di); } sort(v0+1,v0+n+1); int q; scanf("%d",&q); for(int i=1;i<=q;i++) { int t,k; scanf("%d%d",&t,&k); printf("%.3lf\n",sqrt(2.0*C*t+v0[k]*v0[k])); } } return 0; }