Physics Experiment

Physics Experiment

这个题的关键就在于理解这个弹性碰撞,多个球之间的碰撞可以理解为是互不影响的,可以当作是擦身而过而不是相撞,最后再将其排个序即可。

// Created by CAD on 2020/2/2.
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;
double a[105];
int n,h,r,t;
const double g=10.0;
double cal(int T){
    if(T<0) return h;
    double tt=sqrt(2.0*h/g);
    int k=T/tt;
    double d;
    if(k%2==0)  d=T-k*tt;
    else    d=k*tt+tt-T;
    return h-g*d*d/2;
}
int main()
{
    int q;  cin >> q;
    while(q--){
        cin>>n>>h>>r>>t;
        for(int i=0;i<n;++i)
            a[i]=cal(t-i);
        sort(a,a+n);
        for(int i=0;i<n;++i)
        {
            printf("%.2f",a[i]+2*r*i/100.0);
            if(i==n-1) cout<<'\n';
            else cout<<' ';
        }
    }
    return 0;
}
posted @ 2020-02-02 15:33  caoanda  阅读(143)  评论(0编辑  收藏  举报