Pinball HDU - 6373 (高中物理,我佛)

There is a slope on the 2D plane. The lowest point of the slope is at the origin. There is a small ball falling down above the slope. Your task is to find how many times the ball has been bounced on the slope. 

It's guarantee that the ball will not reach the slope or ground or Y-axis with a distance of less than 1 from the origin. And the ball is elastic collision without energy loss. Gravity acceleration g=9.8m/s2g=9.8m/s2. 

Input

There are multiple test cases. The first line of input contains an integer T (1 ≤≤ T ≤≤ 100), indicating the number of test cases. 

The first line of each test case contains four integers a, b, x, y (1 ≤≤ a, b, -x, y ≤≤ 100), indicate that the slope will pass through the point(-a, b), the initial position of the ball is (x, y).

Output

Output the answer. 

It's guarantee that the answer will not exceed 50.

Sample Input

1
5 1 -5 3

Sample Output

2

 

// 把这个反弹的过程放一下 我们把g分解 一个沿着垂直于平面的方向 一个沿着平行于平面的方向 

在平行于平面方向上做匀加速运动 

在垂直于平面方向上加速度一直为g*cos(a1)但是由于碰撞方向会改变

于是我们在两个方向上由其加速度和位移列出两个方程  h = \frac{1}{2}g_2{t_2}^2    s = \frac{1}{2}g_1{t_1}^2 
然后再根据几何知识算出x,y,从而求出时间平行于平面和垂直于平面的时间 t1,t2

然后最后得出ans=1+((t1-t2)/(2*t2))  // 减去从开始点到第一次落到斜面的时间 然后再加上第一次落在斜面上那一次  要除以两倍的t1(弹起来 速度减小到0然后再增大)

 

代码如下

#include<cstdio>
#include<cmath>
using namespace std;
const double g=9.8;
int main()
{
	int T;
	scanf("%d", &T);
	while(T--)
    {
		double a, b, x, y;
		scanf("%lf%lf%lf%lf",&a,&b,&x,&y);
		double costh=cos(atan(abs(b/a))),sinth=sin(atan(abs(b/a)));
		double h=(y-(-x)*b/a)*costh,s=(y-(-x)*b/a)*sinth+(-x)/costh;
		double t1=sqrt(2.0*s/(g*sinth)),t2=sqrt(2.0*h/(g*costh));
		int ans=1+(int)((t1-t2)/(2.0*t2));
		printf("%d\n", ans);
	}
	return 0;
}

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值