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
  • 相关阅读:
    【翻译】ASP.NET Web API入门
    ASP.NET Web API 简介
    浅析利用MetaWeblog接口同步多个博客
    说说JSON和JSONP,也许你会豁然开朗
    说说JSON和JSONP,也许你会豁然开朗
    点击ListView 获取所选择行的数据
    Label 控件设置背景透明色
    C#遍历窗体所有控件或某类型所有控件 (转)
    使用Window 自带的控件 axWindowsMediaPlayer 制作播放器
    ASP.net 学习路线(详细)
  • 原文地址:https://www.cnblogs.com/Rhythm-/p/9445257.html
Copyright © 2011-2022 走看看