hdu 6373 Pinball

版权声明:本文为博主原创文章,转载请附上原博客链接。 https://blog.csdn.net/Dale_zero/article/details/82356942

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6373

将重力加速度分解成垂直平面与平行于平面两个分加速度,然后用时间做一下计算就ok,注意平行于斜面的距离计算要到垂直于远点o为止,而不是到y轴。

#include<bits/stdc++.h>
#include<math.h>
#define mod 1000000007
#define For(i,m,n) for(int i=m;i<=n;i++)
#define LL long long
#define lan(a,b) memset(a,b,sizeof(a))
#define sqr(x) (x*x)
using namespace std;

const double g=9.8;
const double pi=atan(1.0)*4;

int main()
{
    int t;
    scanf("%d",&t);
    while(t--)
    {
        double a,b,x,y;
        scanf("%lf%lf%lf%lf",&a,&b,&x,&y);
        x=-x;
        double a1=atan(b/a);
        double g1=g*cos(a1),g2=g*sin(a1);
        double x1=cos(a1)*(y-x*tan(a1));
        double s=x/cos(a1)+x1*tan(a1);
        double t=sqrt(2*s/g2);
        double t1=sqrt(2*x1/g1);
        int ans=(int)(t/t1);
        if(ans==1)
            printf("1\n");
        else
        {
            ans--;
            ans/=2;
            printf("%d\n",ans+1);
        }
    }
    return 0;
}

猜你喜欢

转载自blog.csdn.net/Dale_zero/article/details/82356942