题意:

给你N个炮弹的发射速度,以及炮台高度H和L1,R1,L2,R2。

问任选发射角度。最多能有几个炮弹在不打入L2~R2的情况下打入L1~R1

注意:区间有可能重叠。

思路:

物理题,发现单纯的依据V去求X很困难。

这个时候想到暴力枚举角度。for(double i=0; i<=pi; i+=0.0007)

算出能到达的x。然后推断x,统计sum

发现以增长级0.0007弧度 刚刚好能过这道题

反正也是醉了~

代码:

#include"cstdlib"
#include"cstdio"
#include"cstring"
#include"cmath"
#include"queue"
#include"algorithm"
#include"iostream"
using namespace std;
double pi=acos(-1.0);
int main()
{
int n;
while(scanf("%d",&n),n)
{
int ans=0;
double h,x1,y1,x2,y2;
double v[222];
scanf("%lf%lf%lf%lf%lf",&h,&x1,&y1,&x2,&y2);
for(int i=0;i<n;i++) scanf("%lf",&v[i]);
for(double i=0; i<=pi; i+=0.0007)
{
int sum=0,f=1;
for(int j=0; j<n; j++)
{
double vx,vy;
double a,b,c;
double x,t;
vx=sin(i)*v[j];
vy=cos(i)*v[j];
a=4.9;
b=vy;
c=-h;
t=(-b+sqrt(b*b-4*a*c))/(2*a);
x=vx*t;
if(x>=x2 && x<=y2)
{
f=0;
break;
}
if(x>=x1 && x<=y1) sum++;
}
if(f) ans=max(ans,sum);
}
printf("%d\n",ans);
}
return 0;
}

[物理题+枚举] hdu 4445 Crazy Tank的更多相关文章

  1. hdu 4445 Crazy Tank (暴力枚举)

    Crazy Tank Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total ...

  2. hdu 4445 Crazy Tank(物理过程枚举)

    遇到物理题,千万不要一味的当成物理题去想着推出一个最终结果来,这样ACM竞赛成了物理比赛,出题人就没水平了...往往只需要基础的物理分析,然后还是用算法去解决问题.这题n小于等于200,一看就估计是暴 ...

  3. HDU 4445 Crazy Tank --枚举

    题意: n个物体从高H处以相同角度抛下,有各自的初速度,下面[L1,R1]是敌方坦克的范围,[L2,R2]是友方坦克,问从某个角度抛出,在没有一个炮弹碰到友方坦克的情况下,最多的碰到敌方坦克的炮弹数. ...

  4. HDU 4445 Crazy Tank 高中物理知识忘得差不多了

    题意不难理解,仔细看题吧,就不说题意了 #include <iostream> #include <cstdio> #include <cstring> #incl ...

  5. hdu 4445 Crazy Tank

    #include <iostream> #include <cstdio> #include <cstring> #include <algorithm> ...

  6. hdoj 4445 Crazy Tank 物理题/枚举角度1

    Crazy TankTime Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total S ...

  7. hdu 5761 Rower Bo 物理题

    Rower Bo 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5761 Description There is a river on the Ca ...

  8. hdu 5066 小球碰撞(物理题)

    http://acm.hdu.edu.cn/showproblem.php?pid=5066 中学物理题 #include <cstdio> #include <cstdlib> ...

  9. HDU 1155 Bungee Jumping(物理题,动能公式,弹性势能公式,重力势能公式)

    传送门: Bungee Jumping Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Othe ...

随机推荐

  1. tarfile/zipfile/shutil

    当我们选择使用Python来进行Linux系统管理,那么就免不了会在Python代码中对压缩包进行处理,包括创建压缩包.解压.获取压缩包中的文件列表等 tarfile Python的tarfile标准 ...

  2. CSS 笔记——定位尺寸

    3. 定位尺寸 -> 尺寸 (1)height 基本语法 height : auto | length 语法取值 auto : 默认值.无特殊定位,根据HTML定位规则分配 length : 由 ...

  3. BZOJ 3399 [Usaco2009 Mar]Sand Castle城堡(贪心)

    [题目链接] http://www.lydsy.com/JudgeOnline/problem.php?id=3399 [题目大意] 将一个集合调整成另一个集合中的数,把一个数+1需要消耗x,-1需要 ...

  4. 【模拟+递归+位运算】POJ1753-Flip Game

    由于数据规模不大,利用爆搜即可.第一次用位运算写的,但是转念一想应该用递归更加快,因为位运算没有剪枝啊(qДq ) [思路] 位运算:时间效率较低(172MS),有些辜负了位运算的初衷.首先将二维数组 ...

  5. HDU 5636 Shortest Path 暴力

    Shortest Path 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5636 Description There is a path graph ...

  6. CDOJ 1279 班委选举 每周一题 div2 暴力

    班委选举 题目连接: http://acm.uestc.edu.cn/#/status/list?problemId=1279 Description 高考的脚步越来越近了--时间如山涧小溪一般悄无声 ...

  7. gitHub 基础命令

    设置开发人员信息 git config --global user.name "chen" git config --global user.email "xxxxx@q ...

  8. Office(Excel、Word)二次开发——VSTO

    Office(Excel.Word)二次开发——VSTO Office(Excel.Word)二次开发——VSTO Office二次开发模式: 1) VBA(visual studio for app ...

  9. 【maven】ecplise新建maven项目 报错Could not calculate build plan: Plugin org.apache.maven.plugins:maven-resources-plugin

    在ecplise上新建maven项目 报错: Could not calculate build plan: Plugin org.apache.maven.plugins:maven-resourc ...

  10. 初始加载时edittext不自动获取焦点的方法

    在做一个搜索功能时,刚进入界面,edittext直接自动获取焦点,这显然不是我想要的. 那么问题来了:如何关闭EditText自动获取焦点的? 尝试了好几个方法,在Java代码添加focus控制,在x ...