@HDU 多校 第六场 Pinball: (物理题)

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

 

 

Source

2018 Multi-University Training Contest 6

[题意]

一个小球,从高处自由落体,弹起来, 问谈几次可以谈到地上

[思路]

物理题, 画图分析

@HDU 多校 第六场 Pinball: (物理题)_第1张图片

可根据 图分析

自由落体 \tiny d2 = \frac{1}{2}*g*t^2 ; v = g * t 求得v,

根据三角形 求得 \tiny d1 = \frac{b}{a}*x ; S = \sqrt{x^2+d1^2}

受力分解: \tiny v_{x} = v*sin(\theta) ; v_{y} = v*cos(\theta) ; g_{x} = g*sin(\theta) ;g_{y} = g*cos(\theta)

斜抛自由落体求得时间:\tiny t = \frac{2*v_{y}}{g_{y}}; 根据斜面上水平加速运动: \tiny Sx = v_{x}t + \frac{1}{2}g_{x}t^2

暴力枚举几次到达地面

[代码]

#include 
#include 
#define rep(i,a,n) for(int i = a;i<=n;i++)
#define per(i,a,n) for(int i = n;i>=a;i--)
#define Si(x) scanf("%d",&x)

/*
*
* Author : SIZ
*/
typedef long long ll;
const int maxn = 1e6+10;

using namespace std;

double a,b,x,y;
double g = 9.8;
int main()
{
    int t;
    scanf("%d",&t);
    while(t--)
    {
        scanf("%lf %lf %lf %lf",&a,&b,&x,&y);
        x = -x;
        double si = atan(b/a);
        double d1 = b/a * x;
        double d2 = y-d1;
        double v = g*sqrt(2*d2/g);
        double S = sqrt(x*x+ d1*d1);
		double vx = v*sin(si),vy = v*cos(si);
        double gx = g*sin(si),gy = g*cos(si);
		double t2 = 2*vy/gy;
		int ans  = 0;
		double ss = 0;
		for(int i = 1 ;i <= 51;i++)
        {
             ss += vx*t2 + 0.5*gx*t2*t2;
            if(ss > S)
            {
            	printf("%d\n",i);
            	break;
			}
            vx = vx + gx*t2;
        }
    }
    return 0;
}

 

你可能感兴趣的:(***数学***,物理公式推导,物理题)