View Code of Problem 1067

#include <stdio.h>
#include <iostream>
#include <math.h>
#include <string.h>
#include <algorithm>

using namespace std;

const int MAXN=220;

const double PI=acos(-1.0);

const double g=9.8;

double v[MAXN];

double  L1,R1,L2,R2;

double H;

int n;

int ff(double x)//角度为x;
{
    int ret=0;
    for(int i=0;i<n;i++)
    {
        double Vy0=v[i]*sin(x);
        double Vx0=v[i]*cos(x);
        double Vy=sqrt(2*g*H+Vy0*Vy0);
        double t=(Vy-Vy0)/g;
        double d=Vx0*t;
        
        if(d>=L2&&d<=R2)return 0;
        
        if(d>=L1&&d<=R1)ret++;
    }
    return ret;
}
int main()
{
    while(scanf("%d",&n) == 1 && n)
    {
        scanf("%lf%lf%lf%lf%lf",&H,&L1,&R1,&L2,&R2);
        for(int i=0;i<n;i++)
          scanf("%lf",&v[i]);
        double add=PI/360;
        int ans=0;
        for(double x=-PI/2;x<=PI/2;x+=add)
          ans=max(ans,ff(x));
        printf("%d\n",ans);
    }
    return 0;
}

Double click to view unformatted code.


Back to problem 1067