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

Crazy Tank
Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 5033    Accepted Submission(s): 1017

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’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.

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

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

题意
就是告诉你,有个坐标在(0,h)的炮台会以一个角度斜抛n个炸弹,然后问你最多有多少个炸弹能够炸到敌人,却炸不到自己人,敌人在(l1,0)和(r1,0)之间,自己人在(l2,0),(0,r2)之间

题解
枚举角度,然后biubiu的模拟一下,算算物理题~

代码

    double g=9.8;
    double sp[maxn];
    int main()
    {
        int n;
        while(RD(n)!=-1&&n)
        {
            double h,l1,r1,l2,r2;
            RDD(h),RDD(l1),RDD(r1),RDD(l2),RDD(r2);
            REP(i,n)
            {
                RDD(sp[i]);
            }
            int ans=0;
            int sum=0;
            for(double i=-pi/2;i<=pi;i+=pi/1000)
            {
                sum=0;
                REP(ii,n)
                {
                    double vy=sp[ii]*sin(i);
                    double vx=sp[ii]*cos(i);
                    double t0=sqrt(2*g*h+vy*vy)-vy;
                    t0/=g;
                    double d=vx*t0;
                    if(d>=l2&&d<=r2)
                    {
                        sum=0;
                        break;
                    }
                    if(d>=l1&&d<=r1)
                        sum++;
                }
                ans=max(sum,ans);
            }
            cout<<ans<<endl;
        }
    }
时间: 2024-08-08 01:13:27

hdoj 4445 Crazy Tank 物理题/枚举角度1的相关文章

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. T

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 Problem Description Crazy Tank was a famous game about ten years ago. Every child liked it. Time f

[物理题+枚举] hdu 4445 Crazy Tank

题意: 给你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&qu

hdu 4445 Crazy Tank(枚举)

http://acm.hdu.edu.cn/showproblem.php?pid=4445 要求发射的炮弹在都不落在friendly tank区域的条件下落在enemy tank区域的最多数目. 直接暴力枚举角度.. #include <stdio.h> #include <iostream> #include <map> #include <set> #include <bitset> #include <list> #inclu

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

遇到物理题,千万不要一味的当成物理题去想着推出一个最终结果来,这样ACM竞赛成了物理比赛,出题人就没水平了...往往只需要基础的物理分析,然后还是用算法去解决问题.这题n小于等于200,一看就估计是暴力枚举能过.就枚举角度就行了. 1 #include<iostream> 2 #include<cstdio> 3 #include<cstdlib> 4 #include<cstring> 5 #include<string> 6 #include

HDU 4445 Crazy Tank --枚举

题意: n个物体从高H处以相同角度抛下,有各自的初速度,下面[L1,R1]是敌方坦克的范围,[L2,R2]是友方坦克,问从某个角度抛出,在没有一个炮弹碰到友方坦克的情况下,最多的碰到敌方坦克的炮弹数. 解法: 枚举角度,将pi/2分成1000份,然后枚举,通过方程 v*sin(theta)*t - 1/2*g*t^2 = -H 解出t,然后 x = v*cos(theta)*t算出水平距离,直接统计即可. 代码: #include <iostream> #include <cstdio&

一道物理题

好久没来填坑了[手动捂脸熊] 啦啦啦物理考试终于结束了.. 所以水一波物理题...看!下!面!↓ 逃离(escape)Description 可怜的江流儿被困在了一个正 N 边形的中心.而追捕它的 N 只山妖存在于 正 N 边形的每个顶点上.山妖们按照顺时针方向,用 1~N 标号,因为山妖很傻, 所以每个山妖 i 都会朝 i+1 号山妖以一个固定的速率移动,移动方向会随着 i+1 位置变化而变化(N 号山妖朝 1 号山妖),最终所有山妖都将到达正 N 边形的 中心,也即江流儿的位置,从而完成追捕

hdoj 3157 Crazy Circuits 【有下界最小流】

题目:hdoj 3157 Crazy Circuits 题意:现在要制造一个电路板,电路板上有 n 个电子元件,各个元件之间有单向的电流流向,然后有一个 + ,电流进入, -- 电流汇入,然后判断能不能让电路板工作,如果能的话求最小电流. 分析:有上下界网络流,求最小流 首先是判断能不能够让电路板工作,能工作的条件就是流量平衡,判断方法前面题目中讲过. 同样先转换为无源汇网络流问题,添加t→ s边权为无穷.那么最小流不就是在满足所有下界的情况的流么.即上面提到的,求得SS→ TT的最大流之后,其

从物理执行的角度透视Spark Job(DT大数据梦工厂)

内容: 1.再次思考pipeline: 2.窄依赖物理执行内幕: 3.宽依赖物理执行内幕: 4.Job提交流程: 物理执行是更深层次的角度. ==========再次思考pipeline ============ 即使采用pipeline的方式,函数f对依赖的RDD中的数据集合的操作也会有两种方式: 1.f(record),f作用于集合的每一条记录,每次只作用于一条记录: 2.f(records), f一次性作用于集合的全部数据: Spark运行的时候用的是第一种方式,为什么呢? 1.无需等待,