2018 Multi-University Training Contest 6: L. Pinball(物理)

 

Pinball

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)
Total Submission(s): 307    Accepted Submission(s): 126

Problem Description

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

将重力加速度分解成垂直斜坡和平行斜坡两个方向。考虑这两个方向的分运动
垂直斜坡方向,小球周期性的弹起下落
平行斜坡方向,小球做匀加速直线运动
只要算出垂直斜坡方向的分运动的周期,和平行斜坡方向分运动的总时间,除一下就是答案

#include<stdio.h>
#include<math.h>
int main(void)
{
	int T;
	double x, y, a, b, c, gx, gy, vx, vy, v, len, t, t2;
	scanf("%d", &T);
	while(T--)
	{
		scanf("%lf%lf%lf%lf", &a, &b, &x, &y);
		x = -x;
		c = sqrt(a*a+b*b);
		len = x*c/a;
		v = sqrt(19.6*(y-b*x/a));
		vx = v*b/c, gx = 9.8*b/c;
		vy = v*a/c, gy = 9.8*a/c;
		t = (sqrt(vx*vx+2*gx*len)-vx)/gx;
		t2 = 2*vy/gy;
		printf("%d\n", (int)(t/t2)+1);
	}
	return 0;
}

猜你喜欢

转载自blog.csdn.net/Jaihk662/article/details/81516396
今日推荐