zoukankan      html  css  js  c++  java
  • hdu4445 CRAZY TANK 2012金华赛区现场赛D题

    简单推下物理公式  对角度枚举


    物理公式不会推啊智商捉急啊。。。。

    到现在没想通为什么用下面这个公式就可以包括角度大于90的情况啊。。。


    #include<iostream>
    #include<cmath>
    #include<cstdio>
    #include<vector>
    #include<cstring>
    #include<algorithm>
    using namespace std;
    #define inf 0x3f3f3f3f
    const double pi=acos(-1.0);
    const double g=9.8;
    
    int main()
    {
        int n,ans,sum,i,flag;
        double h,agl,l1,l2,r1,r2,v[205],l;
        while(scanf("%d",&n)&&n)
        {
            scanf("%lf%lf%lf%lf%lf",&h,&l1,&r1,&l2,&r2);
            for(i=0;i<n;i++)
                scanf("%lf",&v[i]);
            agl=0;
            ans=0;
            while(agl<=pi)
            {
                sum=0;
                for(i=0,flag=1;i<n;i++)
                {
                    //l=vx*t (gt+vy)2-vy2=2gh
                    l=v[i]*sin(agl)*(sqrt(v[i]*v[i]*cos(agl)*cos(agl)+2*g*h)-v[i]*cos(agl))/g;
                    if(l>=l2&&l<=r2)
                    {
                        flag=0;
                        break;
                    }
                    else if(l>=l1&&l<=r1)
                        sum++;
                }
                if(flag) ans=max(ans,sum);
                agl+=(pi/1000);
            }
            printf("%d
    ",ans);
        }
        return 0;
    }
    


  • 相关阅读:
    vuex插件
    axios
    token登录验证
    mysql模糊查询
    Koa2+Mysql搭建简易博客
    正则匹配器
    编码
    Maven学习
    防止重复提交保证幂等的几种解决方案
    策略模式优化if-else
  • 原文地址:https://www.cnblogs.com/javawebsoa/p/3239189.html
Copyright © 2011-2022 走看看