2018HDU more than school sixth 6373 Pinball League

The meaning of problems

Given a slant, from somewhere to make a small ball for free fall, seeking the number of collisions ball and slope (assuming that both elastic collision).

analysis

FIG problem as follows, x axis, y axis is virtual.

The high school physics routines, the gravitational acceleration can be exploded along directions inclined surface.

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

const double g = 9.8;
const double EXP = 0.000001;
double a, b, x, y;

int main()
{
    int T;
    scanf("%d", &T);
    while(T--)
    {
        scanf("%lf%lf%lf%lf", &a, &b, &x, &y);
        if(a * y + b * x < EXP)
        {
            printf("0\n" );
             Continue ; 
        } 
        Double Sinn = B / sqrt (A * A + B * B), Coss = A / sqrt (A * A + B * B);
         Double all_t = sqrt ( 2 * ((X / Coss) * (Sinn - . 1 / Sinn) + Y) / G);   // along ramp time 
        Double T = sqrt ( 2 * (X * Y + Sinn / Coss) / G);    // vertical ramp single time
         / / the printf ( "% F% F \ n-", all_t, T); 
        int tmp = ( int ) ((all_t + the EXP) / T); 
        the printf ( " % D \ n- " , (tmp + . 1 ) / 2  ) ;
    }
    return 0;
}

 

Guess you like

Origin www.cnblogs.com/lfri/p/11329711.html