High school physics oblique throw movement, the simple analysis angle fixed down can calculate each cannonball's landing coordinate lnd.
So violence calculates results at different angles.
#include <cstdio> #include "cmath" #include "algorithm" #define LL long long#define DD double#define N 205#define g 9.8 #define EPS 1e-6const DD pi=acos ( -1.0); ll h,l1,l2,r1,r2,n;dd v[n];using namespace Std;int main () {while (scanf ("%d",& N) {scanf ("%d%d%d%d%d", &H,&L1,&R1,&L2,&R2), for (int i=1;i<=n;i++) scanf ("%lf", &v[i]) ; int Lans=0;for (dd d=0;d<1;d+=1./360) {int ans=0,ok=1;dd s=sin (d*pi);dd C=cos (D*PI); for (int i=1;i<=n;i++) {dd vx= V[I]*S;DD vy=v[i]*c;dd t= (sqrt (2*h*g+vy*vy)-vy)/g;dd lnd=vx*t;if (lnd>=l2&&r2>=lnd) {ok=0;break;} if (LND>=L1&&R1>=LND) ans++;} if (OK) Lans=max (Ans,lans);} printf ("%d\n", LANs);}}
"HDU 4445" Crazy Tank (violence)