天天看點

2018暑假多校賽【第六場】【高中實體】-Pinball-YZHHHHHHHPinball

Pinball

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)

Total Submission(s): 447    Accepted Submission(s): 189

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.

2018暑假多校賽【第六場】【高中實體】-Pinball-YZHHHHHHHPinball

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 Outpu

2

題意:

有一個小球在(x,y)點自由落體到斜率為(-b/a)的斜坡上,做完全彈性碰撞,終點為原點,問小球能夠彈幾次

題解:

這道題,高中生一定能做出來,留下了學渣的淚水。

2018暑假多校賽【第六場】【高中實體】-Pinball-YZHHHHHHHPinball

這道題隻有重力一個力,那麼我們可以把重力分解為兩個力,aa垂直slope, a0平行于slope向右。

那麼這個小球作的運動就是:1、向右不斷加速    2、上下跳動同樣的高度

簡單來說把slope水準放置的時候,一切都清楚了

2018暑假多校賽【第六場】【高中實體】-Pinball-YZHHHHHHHPinball

求出總路程的時間,在除以上下一次的時間,就是彈跳的次數

代碼

#include <stdio.h>
#include <math.h>
using namespace std;
#define 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 d = sqrt(a*a + b*b);
		double k = (-1.0*b/a);
		//double h = abs((k*x + y) / d);
		double h = y-(k*x);
		double hh = a*h/d;
		double hhh = b*h/d;
		double dd = sqrt(x*x + k*x*k*x);
		double a0 = b*g/d;
		double aa = a*g/d;
		double t = sqrt(2*hh/aa);
		double s = dd+hhh;
		double tt = sqrt(2*s/a0);
		int sum = tt/t;
		//printf("g=%lf\n", g);
		sum -= 1;
		sum /= 2;
		sum += 1;
		//printf("hhh=%lf\n",hhh);
		//printf("tt=%lf t=%lf\n", tt, t);
		printf("%d\n",sum);
		
	}
}