杭电多校第六场 Pinball(物理)

Pinball

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


 

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

 

Source

2018 Multi-University Training Contest 6

思路:垂直于斜面上做周期运动,平行于斜面做匀加速运动,用总时间除每一次的周期时间+1

#include <bits/stdc++.h>
using namespace std;

int main(void)
{
    int T;
    double a,b,x,y,g1,g2,v1,v2,v3,t1,t2;
    int ans;
    scanf("%d",&T);
    while(T--) {
        scanf("%lf %lf %lf %lf",&a,&b,&x,&y);
        double ta = atan2(b , a);
        double dn = 9.8 * (y - (-x) * (b / a));//第一次接触斜面的动能
        g1 = 9.8 * cos(ta);//垂直斜面的加速度
        g2 = 9.8 * sin(ta);//平行斜面的加速度
        v1 = sqrt(2 * dn) * cos(ta);//垂直斜面的的初速度
        v2 = sqrt(2 * dn) * sin(ta);//平行斜面的的初速度
        t1 = 2 * (v1 / g1);//一次周期的时间
        v3 = sqrt(2 * g2 * (-x) / cos(ta) + v2 * v2);//平行斜面的末速度
        t2 = (v3 - v2) / g2;//总时间
        ans = (int)(t2 / t1) + 1;
        printf("%d\n",ans);
    }
    return 0;
}
//1.277753 1.751581
//1.277753 4.551381

猜你喜欢

转载自blog.csdn.net/GYH0730/article/details/81571644
今日推荐