HDU 4445 crazy tank (Simple physics, enumeration)

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): 1835 accepted submission (s): 265

Problem descriptioncrazy tank was a famous game about ten years ago. Every child liked it. Time flies, children grow up, but the memory of happy childhood will never go.

Now you're controlling the tank laotu on a platform which is H meters abve the ground. laotu is so old that you can only choose a shoot angle (all the angle is available) before Game start and then any adjusting is Not Allowed . You need to launch n cannonbils and you know that the I-th cannonball's initial speed is vi.
On the right side of laotu there is an enemy tank on the ground with coordination (L1, R1) and a friendly tank with coordination (L2, R2 ). A cannonball is considered hitting enemy tank if it lands on the ground between [L1, R1] (two ends are supported DED ). as the same reason, it will 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 cannonbils which hit the enemy tank under the condition that no cannonball hits friendly tank.
The G equals to 9.8.

 

Inputthere are multiple test case.
Each test case contains 3 lines.
The first line contains an integer N (0 ≤ n ≤ 200), indicating the number of cannonbils 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. two 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.

 

Outputfor each test case, you shoshould output an integer in a single line which indicates the Max number of cannonbils hit the enemy tank under the condition that no cannonball hits friendly tank.

 

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

 

Sample output1 0

Hint

In the first case one of the best choices is that shoot the cannonbils parallelly to the horizontal line, then the first cancannonball 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 [] on the condition that no cannonball lands between [].

 

Source2012 Asia Jinhua Regional Contest

 

Recommendzhuyuanchen520.
# Include <stdio. h> # Include <Iostream> # Include <Math. h> # Include < String . H> # Include <Algorithm>Using   Namespace  STD;  Const   Int Maxn = 220  ;  Const   Double Pi = ACOs (- 1.0  );  Const   Double G = 9.8  ;  Double V [maxn];  Double  L1, R1, L2, R2;  Double  H;  Int  N;  Int Ff ( Double X) //  Angle X;  {  Int Ret = 0  ;  For (Int I = 0 ; I <n; I ++ ){  Double Vy0 = V [I] * Sin (X );  Double Vx0 = V [I] * Cos (X );  Double Vy = SQRT ( 2 * G * H + vy0 * Vy0 );  Double T = (Vy-Vy0 )/ G;  Double D = vx0 *T;  If (D> = L2 & D <= R2) Return   0  ;  If (D> = L1 & D <= R1) RET ++ ;}  Return  RET ;}  Int  Main (){  While (Scanf ( "  % D  " , & N) =1 && N) {scanf (  "  % Lf  " , & H, & L1, & R1, & L2 ,& R2 );  For ( Int I = 0 ; I <n; I ++ ) Scanf (  "  % Lf  " ,& V [I]); Double Add = PI/ 1000  ;  Int Ans = 0  ;  For ( Double X =-PI/ 2 ; X <= PI/ 2 ; X + = Add) ans = Max (ANS, FF (x); printf (  "  % D \ n "  , ANS );}  Return   0  ;} 

 

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.