HDU-4445 (crazy tank 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): 2470 accepted submission (s): 421


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
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
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 tanksMay 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 Input

210 10 15 30 3510.020.0210 35 40 2 3010.020.00
 


Sample output

10HintIn 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]. 
 


Source2012 Asia Jinhua Regional Contest


Recommendzhuyuanchen520

This question is really sad. I am there to complete it, but I still cannot finish it at the end.

In the end, it turned out to be an enumeration brute-force question. I was so disgusted with myself. It turns out that it cannot be true. the rigorous thinking of physics is sometimes very different from the thinking of this informatics competition !!!


As long as the enumeration reaches 0.5 degrees, I will shed tears...

Do not want to write, paste others' code:


# 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) // The angle is 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/360; 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.