设为首页 加入收藏

TOP

HDOJ 4445 Crazy Tank
2015-07-20 17:43:27 来源: 作者: 【 】 浏览:4
Tags:HDOJ 4445 Crazy Tank


枚举角度

Crazy Tank

Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 4305 Accepted Submission(s): 833


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 will never go.
\

Now you???http://www.2cto.com/kf/ware/vc/" target="_blank" class="keylink">vcmUgY29udHJvbGxpbmcgdGhlIHRhbmsgTGFvdHUgb24gYSBwbGF0Zm9ybSB3aGljaCBpcyBIIG1ldGVycyBhYm92ZSB0aGUgZ3JvdW5kLiBMYW90dSBpcyBzbyBvbGQgdGhhdCB5b3UgY2FuIG9ubHkgY2hvb3NlIGEgc2hvb3QgYW5nbGUoYWxsIHRoZSBhbmdsZSBpcyBhdmFpbGFibGUpIGJlZm9yZSBnYW1lIHN0YXJ0IGFuZCB0aGVuIGFueSBhZGp1c3RpbmcgaXMgPHN0cm9uZz5ub3QgYWxsb3dlZDwvc3Ryb25nPi4gWW91IG5lZWQgdG8KIGxhdW5jaCBOIGNhbm5vbmJhbGxzIGFuZCB5b3Uga25vdyB0aGF0IHRoZSBpLXRoIGNhbm5vbmJhbGyhr3MgaW5pdGlhbCBzcGVlZCBpcyBWaS48YnI+Ck9uIHRoZSByaWdodCBzaWRlIG9mIExhb3R1IFRoZXJlIGlzIGFuIGVuZW15IHRhbmsgb24gdGhlIGdyb3VuZCB3aXRoIGNvb3JkaW5hdGlvbihMMSwgUjEpIGFuZCBhIGZyaWVuZGx5IHRhbmsgd2l0aCBjb29yZGluYXRpb24oTDIsIFIyKS4gQSBjYW5ub25iYWxsIGlzIGNvbnNpZGVyZWQgaGl0dGluZyBlbmVteSB0YW5rIGlmIGl0IGxhbmRzIG9uIHRoZSBncm91bmQgYmV0d2VlbiBbTDEsUjFdICh0d28gZW5kcyBhcmUgaW5jbHVkZWQpLiBBcyB0aGUKIHNhbWUgcmVhc29uLCBpdCB3aWxsIGJlIGNvbnNpZGVyZWQgaGl0dGluZyBmcmllbmRseSB0YW5rIGlmIGl0IGxhbmRzIGJldHdlZW4gW0wyLCBSMl0uIExhb3R1"s horizontal coordination is 0.
The goal of the game is to maximize the number of cannonballs which hit the enemy tank under the condition that no cannonball hits friendly tank.
The g equals to 9.8.
Input There are multiple test case.
Each test case contains 3 lines.
The first line contains an 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 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 an integer in a single line which indicates the max number of cannonballs hit the enemy 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 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].
 

Source 2012 Asia JinHua Regional Contest


#include 
   
    
#include 
    
      #include 
     
       #include 
      
        #include 
       
         using namespace std; const double pi=3.1415926,g=9.8; int n,ans; double h,l1,r1,l2,r2; double v[300]; int check(double angle) { int temp=0; for(int i=0;i
        
         =0;i++) { double A=0.5*g; double B=-sin(angle)*v[i]; double C=-h; double time=-B+sqrt(B*B-4*A*C); time=time/(2.*A); double L=time*cos(angle)*v[i]; if( l2<=L && L<=r2 ) { temp=-1; break; } if( l1<=L && L<=r1 ) temp++; } return temp; } int main() { while(scanf("%d",&n)!=EOF&&n) { ans=0; scanf("%lf%lf%lf%lf%lf",&h,&l1,&r1,&l2,&r2); for(int i=0;i
         
          


】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇POJ 1265 Area(计算几何--网格) 下一篇hdu 1671 Phone List (字典树)

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容:

·C++中智能指针的性能 (2025-12-25 03:49:29)
·如何用智能指针实现c (2025-12-25 03:49:27)
·如何在 C 语言中管理 (2025-12-25 03:20:14)
·C语言和内存管理有什 (2025-12-25 03:20:11)
·为什么C语言从不被淘 (2025-12-25 03:20:08)