Hdoj 4445 Crazy Tank Physics Problem/Enumeration angle 1

Source: Internet
Author: User
Tags float number

Crazy Tank
Time limit:2000/1000 MS (java/others) Memory limit:32768/32768 K (java/others)
Total submission (s): 5033 Accepted Submission (s): 1017


problem Description
Crazy Tank was a famous game about ten years ago. Every child liked it. Time flies, children grow up, but the memory of happy childhood would never go.

Now your ' re controlling the tank Laotu on a platform which is H meters above the ground. Laotu is, so, can only choose a shoot angle (all the angle are available) before game start and then any Adjustin G is not allowed. You need to launch N cannonballs and you know that the i-th cannonball ' s initial speed is Vi.
On the right side of Laotu there are an enemy tank in the ground with coordination (L1, R1) and a friendly tank with Coordin ation (L2, R2). A Cannonball is considered hitting enemy tank if it lands on the ground between [L1,R1] (both ends are included). As the same reason, it'll be considered hitting friendly tank if it lands between [L2, R2]. Laotu ' s horizontal coordination is 0.
The goal of the game is to maximize the number of cannonballs which hits the enemy tank under the condition that no cannonb All hits friendly tank.
The g equals to 9.8.


Input
There is multiple test case.
Each test case contains 3 lines.
The first line contains a integer N (0≤n≤200), indicating the number of cannonballs to be launched.
The second line contains 5 float number H (1≤h≤100000), L1, R1 (0<l1<r1<100000) and L2, R2 (0<l2<r2<100000) . indicating the height of the platform, the enemy tank coordinate and the friendly tank coordinate. Tanks may overlap.
The third line contains N float number. The i-th number indicates the initial speed of i-th Cannonball.
The input ends with n=0.


Output
For each test case, you should output a which indicates the max number of cannonballs hits the En Emy tank under the condition that no Cannonball hits friendly tank.


Sample Input

2 10 10 15 30 35 10.0 20.0 2 10 35 40 2 30 10.0 20.0 0



Sample Output

1 0
Hint
In the first case one of the most choices is that shoot the cannonballs parallelly to the horizontal line and then the first Cannonball lands on 14.3 and the second lands on 28.6. In the second there are no shoot angle to make any cannonball land between [35,40] on the condition so no cannonball land s between [2,30].

Test Instructions
is to tell you that there is a coordinate in the (0,h) of the fort will be inclined to throw n bombs at an angle, and then ask you how many bombs can be blown to the enemy, but not to fry their own people, the enemy in (l1,0) and (r1,0) between, one's own in (l2,0), (0,R2) between

Solving
Enumeration angle, then Biubiu simulation, calculate the physics problem ~

Code

    Doubleg=9.8; DoubleSP[MAXN]; intMain () {intN;  while(RD (n)!=-1&&N) {DoubleH,L1,R1,L2,R2;            Rdd (h), Rdd (L1), Rdd (R1), Rdd (L2), RDD (R2);            REP (i,n) {RDD (sp[i]); }            intans=0; intsum=0;  for(Doublei=-pi/2; i<=pi;i+=pi/ +) {sum=0; REP (ii,n) {Doublevy=sp[ii]*sin (i); Doublevx=sp[ii]*cos (i); DoubleT0=SQRT (2*g*h+vy*vy)-VY; T0/=G; Doubled=vx*t0; if(d>=l2&&d<=R2) {Sum=0;  Break; }                    if(d>=l1&&d<=R1) Sum++; } ans=Max (Sum,ans); } cout<<ans<<Endl; }    }

Hdoj 4445 Crazy Tank Physics Problem/Enumeration angle 1

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.