POJ 3684 弹性碰撞

碰撞问题。
弹性碰撞交换速度和方向,可以当成两个质点相互交错而过,不影响最后的结果,因为只需要排序就可以知道,最低的一定是最先放下的,以此类推。

#include<iostream>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<climits>
#include<stack>
#include<vector>
#include<queue>
#include<set>
#include<map>
#define up(i,a,b)  for(int i=a;i<b;i++)
#define dw(i,a,b)  for(int i=a;i>b;i--)
#define upd(i,a,b) for(int i=a;i<=b;i++)
#define dwd(i,a,b) for(int i=a;i>=b;i--)
//#define local
typedef long long ll;
const double esp = 1e-6;
const double pi = acos(-1.0);
const long long INF = 0x3f3f3f3f;
using namespace std;
typedef pair<int, int> pir;
const double g = 10.0;
int c, n,h, r, t;
double solve( int t1)
{
	if (t1 < 0)return h;
	double tempt = sqrt(2 * h / g);
	//cout << tempt << endl;
	double ans;
	int k = t1 / tempt;
	//cout << k << endl;
	if (k & 1)
	{
		ans = (double)h - ((k+1)*tempt-t1)*((k+1)*tempt-t1)*g / 2;
	}
	else
	{
		ans = (double)h - (t1-k*tempt)*(t1-k*tempt )*g / 2;
	}
	return ans;
}
int main()
{
	cin >> c;
	
	while (c--)
	{
		double ans[1005];
		cin >> n >> h >> r >> t;
		//h *= 100;
		up(i, 0, n)
		{
			ans[i] = solve(t - i);	
		}
		sort(ans, ans + n);
		up(i, 0, n)
		{
			printf("%.2f%c", ans[i] + 2.0*r*i / 100.0,(i+1)==n?'\n':' ');
		}
	}
	return 0;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值