遇到物理题,千万不要一味的当成物理题去想着推出一个最终结果来,这样ACM竞赛成了物理比赛,出题人就没水平了。。。往往只需要基础的物理分析,然后还是用算法去解决问题。这题n小于等于200,一看就估计是暴力枚举能过。就枚举角度就行了。
1 #include<iostream> 2 #include<cstdio> 3 #include<cstdlib> 4 #include<cstring> 5 #include<string> 6 #include<cmath> 7 #include<map> 8 #include<set> 9 #include<vector> 10 #include<algorithm> 11 #include<stack> 12 #include<queue> 13 #include<cctype> 14 #include<sstream> 15 using namespace std; 16 #define pii pair<int,int> 17 #define LL long long int 18 const int eps=1e-8; 19 const int INF=1000000000; 20 const int maxn=100000+10; 21 const double pi=acos(-1); 22 const double ds=pi/1000; 23 const double g=9.8; 24 double l1,l2,r1,r2,h,v[210]; 25 int ans,n; 26 int gao(double t) 27 { 28 int res=0; 29 for(int i=0;i<n;i++) 30 { 31 double vx=v[i]*cos(t); 32 double vy=v[i]*sin(t); 33 double vt=sqrt(2*g*h+vy*vy); 34 double t=(vt-vy)/g; 35 double d=vx*t; 36 if(d>=l2&&d<=r2) return 0; 37 else 38 { 39 if(d>=l1&&d<=r1) 40 { 41 res++; 42 } 43 } 44 } 45 return res; 46 } 47 int main() 48 { 49 //freopen("in8.txt","r",stdin); 50 while(scanf("%d",&n)==1&&n) 51 { 52 scanf("%lf%lf%lf%lf%lf",&h,&l1,&r1,&l2,&r2); 53 for(int i=0;i<n;i++) 54 { 55 scanf("%lf",&v[i]); 56 } 57 ans=0; 58 for(double i=-(pi/2);i<=(pi/2);i+=ds) 59 { 60 ans=max(ans,gao(i)); 61 } 62 printf("%d ",ans); 63 } 64 return 0; 65 }