标签:
Description
Input
Output
Sample Input
Sample Output
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\n"); #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\n",ans); } return 0; }
标签:
原文地址:http://www.cnblogs.com/zxhl/p/4784302.html