View Code of Problem 1067

#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
using namespace std;
#define N 205
#define LL __int64
const double eps=1e-9;
const double PI=acos(-1.0);
double h,l1,l2,r1,r2;
double v[N],g=9.8;
int n;
int fun(double anl)
{
    int i,tmp=0;
    double vx,vy1,vy2,t,x;
    for(i=0;i<n;i++)
    {
        vx=v[i]*cos(anl);
        vy1=v[i]*sin(anl);
        vy2=sqrt(vy1*vy1+2*g*h);
        t=(vy1+vy2)/g;
        x=vx*t;
        if(x>=l2 &&x<=r2 )
            return 0;
        if(x>=l1 &&x<=r1 )
            tmp++;
    }
    return tmp;
}
int main()
{
    int i;
    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]);
        }
        double a,add=PI/1000;
        int ans=0;
        for(a=-PI/2;a<=PI/2 ;a+=add)
        {
            int tmp=fun(a);
            ans=max(ans,tmp);
        }
        printf("%d\n",ans);
    }
    return 0;
}

Double click to view unformatted code.


Back to problem 1067