题意
有一堆球,他们在一条线上运动,有各自的初速度,加速度和速度的变化满足Ai⋅Vi=C,如果碰撞,是完全弹性碰撞,然后给出一些询问(t,k),问t时刻时,速度第k小的球的速度。
思路
因为是完全弹性碰撞,最后的询问又和具体的小球没有关系,所以直接当成无碰撞来处理就好了,对初始速度排序,然后只要知道第k小的球在t时刻的速度就行了,这就是高数的活了,过程如下
v⋅a=cv⋅dvdt=cv⋅dv=c⋅dt两边积分得:12v2=ct+C当t=0时:C=12V20所以v=2ct+V20−−−−−−−√
代码
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5+10;
double num[maxn];
int main (){
int T;
scanf("%d", &T);
while(T --){
int n;
double c;
scanf("%d %lf",&n,&c);
int tmp;
for(int i = 0 ; i < n ; i ++){
scanf("%lf", num+i);
scanf("%d",&tmp);scanf("%d",&tmp);
}
sort(num,num+n);
scanf("%d", &n);
while(n --){
int t,k;
scanf("%d %d", &t,&k);
k--;
double ans = sqrt(1LL*num[k]*num[k] + 2LL*c*t);
printf("%.3f\n",ans);
}
}
}