Hdu4445 physical 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): 2729 accepted submission (s): 486


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

210 10 15 30 3510.000000210 35 40 2 3010.0000000


Sample output

10. No language. I can use enumeration. What else do I have to think of? What are the two points and three points? Line tree ,.......
# Include <stdio. h> # include <math. h ># include <iostream> using namespace STD; const double Pi = ACOs (-1); double H, L1, L2, R1, R2, G = 9.8; int N; double V [202]; int fmax (int A, int B) {If (A> B) return a; return B;} int ff (Double X) {int I, sum = 0; for (I = 1; I <= N; I ++) {double X1 = V [I] * Cos (X ); double X2 = V [I] * sin (x); double X3 = SQRT (2 * H * g + x2 * x2); double X4 = (x3-x2)/g * x1; if (X4> = L2 & X4 <= R2) {return 0;} If (X4> = L1 & X4 <= R1 ){ Sum ++ ;}}return sum ;}int main () {int I; while (scanf ("% d", & N )! = EOF) {If (n = 0) break; scanf ("% lf", & H, & L1, & R1, & L2, & R2); for (I = 1; I <= N; I ++) {scanf ("% lf", & V [I]);} Double X; double add = PI/1000.0; int max =-1; for (x =-PI/2.0; x <= PI/2.0; X ++ = add) {max = fmax (max, FF (x) ;}printf ("% d \ n", max) ;}return 0 ;}

 


Source2012 Asia Jinhua regional
Contest

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.