思路与蚂蚁碰撞相似,但要处理半径的关系,其实权当都从高度为H的地方落下,半径为0,最后加上刚开始的高度差即可。
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
const int maxn=105;
const double g=10.0;
int N,H,R,T;
double Y[maxn];
double cal(int k){
if(k<0) return H;
double t=(double)sqrt(2*H/g);
int m=k/t;
if(m&1){
double t1=(m+1)*t-k;
return H-g*t1*t1/2.0;
}else{
double t1=k-m*t;
return H-g*t1*t1/2.0;
}
}
int main()
{
int t;
cin>>t;
while(t--){
cin>>N>>H>>R>>T;
for(int i=0;i<N;i++){
Y[i]=cal(T-i);
}
sort(Y,Y+N);
for(int i=0;i<N;i++){
printf("%.2f%c",Y[i]+2.0*R*i/100.0,i==N-1?'\n':' ');
}
}
return 0;
}