版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/V5ZSQ/article/details/82562823
Description
一个过点 、位于第二象限的斜坡,一小球从 落下,假设其与斜坡的碰撞是完全非弹性碰撞,问小球的碰撞次数
Input
第一行一整数 表示用例组数,每组用例输入四个整数
Output
输出碰撞次数
Sample Input
1
5 1 -5 3
Sample Output
2
Solution
将重力加速度 分解为沿斜面方向 和垂直于斜面方向 ,那么在垂直于斜面方向小球做自由落体以及逆运动往返,而在沿斜面方向做以 为加速度的匀加速直线运动,假设自由落体时间为 ,在沿斜面方向的运动时间为 ,那么碰撞次数即为
Code
#include<cstdio>
#include<cmath>
using namespace std;
int main()
{
int T,a,b,x,y;
scanf("%d",&T);
while(T--)
{
scanf("%d%d%d%d",&a,&b,&x,&y);
double h=y+1.0*x*b/a,c=sqrt(1.0*a*a+1.0*b*b),g=9.8;
double s=h*b/c+sqrt(1.0*x*x+1.0*(h-y)*(h-y));
double ax=g*b/c,ay=g*a/c;
double t1=sqrt(2.0*s/ax),t2=sqrt(2.0*h/g);
printf("%d\n",1+(int)((t1-t2)/(2.0*t2)));
}
return 0;
}