题目:
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
.
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 = 9.8, 碰撞过程中无能量损失, 计算小球碰触斜面的次数。
题解:关键只在于正交分解, 分析了小球垂直斜面方向运动的时间循环之后有多种方式计算结果。以斜面做正交分解后讲小球的运动以及受力分成沿斜面和垂直斜面方向, 垂直斜面方向小球从初速度为零起做匀加速运动, 碰触斜面后速度瞬间反向, 再做匀减速直至垂直斜面方向速度为零, 而沿斜面方向小球一直做匀加速运动。运动过程分析透彻了题目也就很简单的解决了~(用高中老师的话来说这种题就是送分的题)
AC代码:
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
double g = 9.80;
int main()
{
int i, j, n , ans, T;
double a, b, x, y, hi, t, t2, v, s;
scanf("%d", &T);
while(T--){
ans = 0;
scanf("%lf %lf %lf %lf", &a, &b, &x, &y);
hi = x / a * b + y;
s = sqrt(-x / a * b * -x / a * b + x * x);
t = sqrt(2 * hi / g);
v = g * t * b / sqrt(b * b + a * a);
t2 = t * t;
while(s > 0){
s -= v * 2 * t + g * b / sqrt(b * b + a * a) * 2 * t2;
v += g * b / sqrt(b * b + a * a) * 2 * t;
ans++;
}
printf("%d\n",ans);
}
return 0;
}