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/s2.
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 the answer.
It’s guarantee that the answer will not exceed 50.
1
5 1 -5 3
2
给出一个斜坡和一个小球,小球自由落体向下运动,不考虑能量损失,问小球能在斜坡上反弹几次。
已知图上的 a,b,x,y a , b , x , y
首先把小球反弹后的速度进行分解,如下图
把速度分解成沿着斜坡方向和垂直于斜坡方向。
把重力加速度也分解成沿着斜坡方向和垂直于斜坡方向
那么我们就可以知道:
因为小球下落到斜坡上和斜坡反弹小球到最高点用的时间是一样的,所以我们可以计算出小球碰撞两次所需要的时间,每一次小球在斜坡上反弹的时间都一样,那么这个过程就可以相当于把斜坡当成x轴把垂直于斜坡当成y轴,相当于一个小球在上面不听的反弹,但是又向右加速运动,我们利用每一次反弹的时间和速度就可以计算出位移比
t=2∗vygy=2∗2gh√∗cosαg∗cosα=22gh√g t = 2 ∗ v y g y = 2 ∗ 2 g h ∗ c o s α g ∗ c o s α = 2 2 g h g
那么反弹一次的位移为:
x1=vxt+12gxt2=2gh−−−√∗sinα∗2∗2gh√g+12gsinα∗(2∗2gh√g)2=8hsinα x 1 = v x t + 1 2 g x t 2 = 2 g h ∗ s i n α ∗ 2 ∗ 2 g h g + 1 2 g s i n α ∗ ( 2 ∗ 2 g h g ) 2 = 8 h s i n α
第二次的速度为:
vx′=vx+gxt=2gh−−−√∗sinα+gsinα∗2∗2gh√g=32gh−−−√∗sinα v x ′ = v x + g x t = 2 g h ∗ s i n α + g s i n α ∗ 2 ∗ 2 g h g = 3 2 g h ∗ s i n α
那么现在就可以推导出速度比: v1:v2:v3=1:3:5 v 1 : v 2 : v 3 = 1 : 3 : 5
位移比: x1:x2:x3=1:2:3 x 1 : x 2 : x 3 = 1 : 2 : 3
最后我们知道了位移比,我们只需要计算出斜面的长度按照比值向上加,知道大于斜坡长度时输出。
#include
using namespace std;
#define mem(a,b) memset(a,b,sizeof(a))
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
typedef long long ll;
const double pi=acos(-1.0);
const int N=1e5+10;
void solve()
{
double a,b,x,y;
scanf("%lf%lf%lf%lf",&a,&b,&x,&y);
double jiao=atan(b/a);
double sina=sin(jiao);
double h=y-b*(-x)/a;
double L=(y-h)/sina;
int ans=0,sum=0;
for(int i=1; i<=50; i++)
{
ans++;
sum+=i;
if((double)sum*8.0*h*sina>L)
{
printf("%d\n",ans);
break;
}
}
}
int main()
{
int t;
scanf("%d",&t);
while(t--)solve();
return 0;
}