zoukankan      html  css  js  c++  java
  • HDU 6373 Pinball

    Pinball

    Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)
    Total Submission(s): 131    Accepted Submission(s): 55
    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.8 m/s^2$.
     
    Input
    There are multiple test cases. The first line of input contains an integer T (1 $le$ T $le$ 100), indicating the number of test cases.

    The first line of each test case contains four integers a, b, x, y (1 $le$ a, b, -x, y $le$ 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
     
    Statistic | Submit | Discuss | Note
    分析:高中物理题可还行,直接正交分解推个公式就好了。
    #include <iostream>
    #include <string>
    #include <cstdio>
    #include <cmath>
    #include <cstring>
    #include <algorithm>
    #include <vector>
    #include <queue>
    #include <deque>
    #include <map>
    #define range(i,a,b) for(auto i=a;i<=b;++i)
    #define LL long long
    #define ULL unsigned long long
    #define elif else if
    #define itrange(i,a,b) for(auto i=a;i!=b;++i)
    #define rerange(i,a,b) for(auto i=a;i>=b;--i)
    #define fill(arr,tmp) memset(arr,tmp,sizeof(arr))
    #define IOS ios::sync_with_stdio(false);cin.tie(0)
    using namespace std;
    int t,a,b,x,y;
    const double g=9.8;
    void init(){
        scanf("%d",&t);
    }
    void solve(){
        while(t--){
            scanf("%d%d%d%d",&a,&b,&x,&y);
            double SIN=b*1.0/sqrt(a*a+b*b);
            double h=y+b*x*1.0/a,l=h*SIN+sqrt(x*x*(1+b*b*1.0/(a*a)));
            double TR=sqrt(2*l/(g*SIN)),T=sqrt(2*h/g);
            int cnt=int(TR/T),ans=(cnt+1)>>1;
            cout<<ans<<endl;
        }
    }
    int main() {
        init();
        solve();
        return 0;
    }
    View Code
  • 相关阅读:
    作业 20181030-3互评Alpha版本
    Alpha阶段事后诸葛亮会议记录
    Alpha发布用户使用报告
    20181023-2 贡献分配
    作业 20181016-1 Alpha阶段贡献分配规则
    Scrum立会报告+燃尽图(十月三十日总第二十一次)
    OC中时间函数的使用
    OC中的集合详解
    面向对象的概念详解(转)
    集中类
  • 原文地址:https://www.cnblogs.com/Rhythm-/p/9445257.html
Copyright © 2011-2022 走看看