hdu 4445 Crazy Tank (暴力枚举)
Crazy Tank
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 4562 Accepted Submission(s): 902

Now you’re controlling the tank Laotu on a platform which is H meters above 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 cannonballs 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 included). 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 cannonballs which hit the enemy tank under the condition that no cannonball hits friendly tank.
The g equals to 9.8.
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<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.
2
10 10 15 30 35
10.0
20.0
2
10 35 40 2 30
10.0
20.0
0
1
0HintIn 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].
这题也是醉了,居然暴力枚举,一直推公式了。
对于[-PI/2,PI/2]区间,每次累加一个较小值。遍历N个区间。求得满足条件最多的那个就是答案。
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
using namespace std;
#define N 205
#define LL __int64
const double eps=1e-9;
const double PI=acos(-1.0);
double h,l1,l2,r1,r2;
double v[N],g=9.8;
int n;
int fun(double anl)
{
int i,tmp=0;
double vx,vy1,vy2,t,x;
for(i=0;i<n;i++)
{
vx=v[i]*cos(anl);
vy1=v[i]*sin(anl);
vy2=sqrt(vy1*vy1+2*g*h);
t=(vy1+vy2)/g;
x=vx*t;
if(x>=l2 &&x<=r2 )
return 0;
if(x>=l1 &&x<=r1 )
tmp++;
}
return tmp;
}
int main()
{
int i;
while(scanf("%d",&n),n)
{
scanf("%lf%lf%lf%lf%lf",&h,&l1,&r1,&l2,&r2);
for(i=0;i<n;i++)
{
scanf("%lf",&v[i]);
}
double a,add=PI/1000;
int ans=0;
for(a=-PI/2;a<=PI/2 ;a+=add)
{
int tmp=fun(a);
ans=max(ans,tmp);
}
printf("%d\n",ans);
}
return 0;
}
版权声明:本文博客原创文章。博客,未经同意,不得转载。
hdu 4445 Crazy Tank (暴力枚举)的更多相关文章
- hdu 4445 Crazy Tank(物理过程枚举)
遇到物理题,千万不要一味的当成物理题去想着推出一个最终结果来,这样ACM竞赛成了物理比赛,出题人就没水平了...往往只需要基础的物理分析,然后还是用算法去解决问题.这题n小于等于200,一看就估计是暴 ...
- [物理题+枚举] hdu 4445 Crazy Tank
题意: 给你N个炮弹的发射速度,以及炮台高度H和L1,R1,L2,R2. 问任选发射角度.最多能有几个炮弹在不打入L2~R2的情况下打入L1~R1 注意:区间有可能重叠. 思路: 物理题,发现单纯的依 ...
- HDU 4445 Crazy Tank --枚举
题意: n个物体从高H处以相同角度抛下,有各自的初速度,下面[L1,R1]是敌方坦克的范围,[L2,R2]是友方坦克,问从某个角度抛出,在没有一个炮弹碰到友方坦克的情况下,最多的碰到敌方坦克的炮弹数. ...
- hdu 4445 Crazy Tank
#include <iostream> #include <cstdio> #include <cstring> #include <algorithm> ...
- HDU 4445 Crazy Tank 高中物理知识忘得差不多了
题意不难理解,仔细看题吧,就不说题意了 #include <iostream> #include <cstdio> #include <cstring> #incl ...
- hdoj 4445 Crazy Tank 物理题/枚举角度1
Crazy TankTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total S ...
- HDU 5778 abs (暴力枚举)
abs Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others) Problem De ...
- HDU 1015.Safecracker【暴力枚举】【8月17】
Safecracker Problem Description === Op tech briefing, 2002/11/02 06:42 CST === "The item is lo ...
- HDU - 5128The E-pang Palace+暴力枚举,计算几何
第一次写计算几何,ac,感动. 不过感觉自己的代码还可以美化一下. 传送门:http://acm.hdu.edu.cn/showproblem.php?pid=5128 题意: 在一个坐标系中,有n个 ...
随机推荐
- 十步完全理解SQL(转)
本文由 伯乐在线 - 水果泡腾片 翻译.未经许可,禁止转载!英文出处:Lukas Eder.欢迎加入翻译组. 很多程序员视 SQL 为洪水猛兽.SQL 是一种为数不多的声明性语言,它的运行方式完全不同 ...
- java命令行HPROF Profiler(转)
The HPROF Profiler The Heap and CPU Profiling Agent (HPROF)是JAVA2 SDK自带的一个简单的profiler代理,它通过与Java Vir ...
- BAE3.0搭建wordpress注意
仅仅是mark一个注意的点,数据库连接时,主机是: /** MySQL主机 */ define('DB_HOST', 'sqld.duapp.com:4050');
- jquery 判断当前上传文件大小限制上传格式 搭配thinkphp实现上传即预览(模拟异步上传)
在web开发中,最纠结的一项就是文件上传,最近由于项目需要前后摸索了四天在这里分享给大家.如有不足,望指出!! 前台:jquery.easyui.html 后台:thinkphp 主要涉及语言:jqu ...
- 让Emeditor支持markdown编辑博客
让Emeditor支持markdown编辑博客 1. 关于高亮显示 2.生成HTML文件并预览 用惯了Emeditor,最近又开始学习用markdown写博客,怎么让Emeditor支持markdow ...
- 深入理解JavaScript系列(33):设计模式之策略模式(转)
介绍 策略模式定义了算法家族,分别封装起来,让他们之间可以互相替换,此模式让算法的变化不会影响到使用算法的客户. 正文 在理解策略模式之前,我们先来一个例子,一般情况下,如果我们要做数据合法性验证,很 ...
- 开源Math.NET基础数学类库使用(10)C#进行基本数据统计
原文:[原创]开源Math.NET基础数学类库使用(10)C#进行基本数据统计 本博客所有文章分类的总目录:http://www.cnblogs.com/asxinyu/p ...
- Sqlserver2000联系Oracle11G数据库进行实时数据的同步
Sqlserver2000联系Oracle11G数据库进行实时数据的同步 1,前提条件 我有sqlserver2000环境,已经存在oracle11g环境,准备这两个数据库,建立各自的訪问账号,两者之 ...
- Linux查看命令终止进程
Linux查看命令终止进程 youhaidong@youhaidong-ThinkPad-Edge-E545:~$ ps PID TTY TIME CMD 2576 pts/0 00:00:00 ba ...
- 它们的定义actionbar 并删除留空
通过他们自己的定义actionbar布局变化actionbar样式,简单而美丽.但有一个细节需要注意的是,高分辨率的问题留空.一般720上述决议,下一次你发现,无论什么样的变化总是会有一个小的布局文件 ...