• HDU 4445 数学-抛物运动


                                                          D - Crazy Tank
                                                    Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u
     

    Description

    Crazy Tank was a famous game about ten years ago. Every child liked it. Time flies, children grow up, but the memory of happy childhood will never go. 

    Now you’re controlling the tank Laotu on a platform which is H meters above the ground. Laotu is so old that you can only choose a shoot angle(all the angle is available) before game start and then any adjusting is not allowed. You need to launch N cannonballs and you know that the i-th cannonball’s initial speed is Vi. 
    On the right side of Laotu There is an enemy tank on the ground with coordination(L1, R1) and a friendly tank with coordination(L2, R2). A cannonball is considered hitting enemy tank if it lands on the ground between [L1,R1] (two ends are included). As the same reason, it will be considered hitting friendly tank if it lands between [L2, R2]. Laotu's horizontal coordination is 0. 
    The goal of the game is to maximize the number of cannonballs which hit the enemy tank under the condition that no cannonball hits friendly tank. 
    The g equals to 9.8.
     

    Input

    There are multiple test case. 
    Each test case contains 3 lines. 
    The first line contains an integer N(0≤N≤200), indicating the number of cannonballs to be launched. 
    The second line contains 5 float number H(1≤H≤100000), L1, R1(0<L1<R1<100000) and L2, R2(0<L2<R2<100000). Indicating the height of the platform, the enemy tank coordinate and the friendly tank coordinate. Two tanks may overlap
    The third line contains N float number. The i-th number indicates the initial speed of i-th cannonball. 
    The input ends with N=0.
     

    Output

    For each test case, you should output an integer in a single line which indicates the max number of cannonballs hit the enemy tank under the condition that no cannonball hits friendly tank.
     

    Sample Input

    2 10 10 15 30 35 10.0 20.0 2 10 35 40 2 30 10.0 20.0 0
     

    Sample Output

    1 0

    Hint

     In the first case one of the best choices is that shoot the cannonballs parallelly to the horizontal line, then the first cannonball lands on 14.3 and the second lands on 28.6. In the second there is no shoot angle to make any cannonball land between [35,40] on the condition that no cannonball lands between [2,30]. 


    题解:角度可以向下,向上,其实都一样的计算.................
    将pi分块枚举,维护最大答案就好了

    ///1085422276
    #include<iostream>
    #include<cstdio>
    #include<cstring>
    #include<string>
    #include<algorithm>
    #include<queue>
    #include<cmath>
    #include<map>
    #include<bitset>
    #include<set>
    #include<vector>
    using namespace std ;
    typedef long long ll;
    #define mem(a) memset(a,0,sizeof(a))
    #define meminf(a) memset(a,127,sizeof(a));
    #define TS printf("111111
    ");
    #define FOR(i,a,b) for( int i=a;i<=b;i++)
    #define FORJ(i,a,b) for(int i=a;i>=b;i--)
    #define READ(a) scanf("%d",&a)
    #define mod 365*24*60*60
    #define inf 100000
    #define maxn 300000
    inline ll read()
    {
        ll x=0,f=1;
        char ch=getchar();
        while(ch<'0'||ch>'9')
        {
            if(ch=='-')f=-1;
            ch=getchar();
        }
        while(ch>='0'&&ch<='9')
        {
            x=x*10+ch-'0';
            ch=getchar();
        }
        return x*f;
    }
    //****************************************
    #define g 9.8
    #define eps 0.0000001
    int n;
    double s[202],H,L1,L2,R1,R2;
    int flag=0;
    int suan(int i,double j)
    {
        double ss=cos(j)*s[i];
        double t=sqrt(2*H/g);
        double d=t*ss;
        if(L1-d<0.0000001)flag=1;
        int sum=0;
        if(d-L1>=0.0000001&&0.0000001<=R1-d)sum++;
        if(d-L2>=0.0000001&&0.0000001<=R2-d) sum--;
        if(sum<0)return 0;
        return  sum;
    }
    int main()
    {
    
        while(READ(n)!=EOF)
        {
            if(n==0)break;
            flag=0;
            scanf("%lf%lf%lf%lf%lf",&H,&L1,&R1,&L2,&R2);
            FOR(i,1,n)
            {
                scanf("%lf",&s[i]);
            }
            int ans=0;
            double vx,vy,xx,yy;
            for(double j=0; j<1000; j+=1)
            {
                double aphl=j*0.003141593;
                int sum=0;
                FOR(i,1,n)
                {
                    vx=s[i]*sin(aphl);
                    vy=s[i]*cos(aphl);
                    xx=((sqrt(vy*vy+2.0*g*H)-vy)/g)*vx;
                    if(xx>L2-eps&&xx<R2+eps)
                    {
                        sum=0;
                        break;
                    }
                    if(xx>L1-eps&&xx<R1+eps)
                        sum++;
                }
                ans=max(sum,ans);
                /// if(flag==1)break;
            }
            printf("%d
    ",ans);
        }
        return 0;
    }
    代码
  • 相关阅读:
    通过PMP了
    VBA之自动建立连接
    从头学SQL Server2005之一:数据库引擎体系结构
    SMP、NUMA、MPP体系结构介绍【转】
    将Windows2003的RDP客户端管理应用于XP
    VBA中简单修改原有公式的宏
    各种Excel VBA的命令
    领导和管理的区别在哪里?【转】
    COM(VB/VBA/Script)利用服务标记调用WCF服务之四:使用配置文件
    2009年第一篇日志
  • 原文地址:https://www.cnblogs.com/zxhl/p/4784302.html
Copyright © 2020-2023  润新知