hdu6373 Pinball 杭电第六场 物理知识

Pinball

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


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
 
Recommend
chendu   |   We have carefully selected several similar problems for you:  6373 6372 6371 6370 6369 
 
题意:一个球从下坡上方落下,求球能在斜坡上弹几次?
分析:将球在斜坡上运动的过程分成两个过程。一种是垂直于斜坡方向上的运动,一种是平行于斜坡方向上的运动。
  因为球每次的弹跳过程是初速度一样的匀加速运动,所以每次弹跳的时间一样。
  因此我们可以通过求出每次球弹跳的时间,再用总时间除以每次的时间就可以得到球弹跳了几次。
  通过球在平行于斜坡方向上的我们可以求出球弹跳的总时间,球在这种运动的总过程里是一个匀加速运动,由 x = vx*t+0.5*ax*t*t可以得到时间t
AC代码:
#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <queue>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <algorithm>
#define ls (r<<1)
#define rs (r<<1|1)
#define debug(a) cout << #a << " " << a << endl
using namespace std;
typedef long long ll;
const ll maxn = 1e3+10;
const ll mod = 1e9+7;
const double pi = acos(-1.0);
const double eps = 1e-8;
int main() {
    ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    ll Tt;
    double a, b, x, y;
    cin >> Tt;
    while( Tt -- ) {
        cin >> a >> b >> x >> y;
        x = -x;
        ///垂直于斜面方向上
        double th = atan(b/a);///斜面角度
        double h = y-x*tan(th);///从下落处到第一次碰撞点的垂直高度
        double g = 9.8;///重力加速度
        double v = sqrt(2*g*h);///第一次碰撞时的速度
        double t = 2*v/g;///小球在垂直斜面方向上运动的周期
        
        ///平行于斜面方向上
        double X = x/cos(th);///小球在斜面上的位移
        double vx = v*sin(th);///小球平行于斜面的分速度
        double A = g*sin(th);///小球平行于斜面的加速度(重力加速度的分速度)
        double T = (sqrt(4*vx*vx+8*A*X)-2*vx)/(2*A);///小球在斜面上运动的总时间
        cout << (ll)(T/t)+1 << endl;///碰撞次数为总时间除以碰撞周期+1(第一次碰撞)
    }
    return 0;
}

  

彼时当年少,莫负好时光。
原文地址:https://www.cnblogs.com/l609929321/p/9450226.html