POJ 3684 (弹性碰撞)

思路与蚂蚁碰撞相似,但要处理半径的关系,其实权当都从高度为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;
 }

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值