编程介的小学生 2020-02-08 12:10 采纳率: 20.5%
浏览 145

Shoot the Airplane 飞机算法思想

Problem Description
XXX is playing an interesting game which is based on a 2D plane. In this game, he is required to shoot an airplane. The airplane flies horizontally. The shape of it can be regarded as a simple polygon. Player has to shoot at point (0, 0) upward vertically. Because the bullet is very small, it can be regarded as a point. The airplane is hit only if the bullet goes into the airplane. The airplane is not hit if the bullet only touches the edge of the airplane. The gravity should be considered. The acceleration of gravity is g and its direction is downward vertically. So the speed of the bullet may be change during flying. But the speed of airplane is constant because it has engines. XXX wants to know the time it takes the bullet to hit the airplane after shooting.

Input
There are multiple cases.
In each case, there are three integers v (-10<= v <= 10), b (1 <= b <= 10), g (0 <= g <= 10) in the first line. v denotes the speed of airplane. The flying direction is from left to right if v is positive and the direction is from right to left if v is negative. b denotes the initial speed of bullet. g is the acceleration of gravity. Then the input will describe the position of the airplane when XXX shoots. In the second line, there is one integer n (3 <= n <= 20) which represents the number of vertexes of the airplane (polygon). In each of the next n lines, there are two integers x (-100 <= x <= 100), y (0 <y<= 100) which give the position of a vertex in order. There is a blank line after each case. The input ends with 0 0 0.

Output
If the airplane is hit, then output the time it takes the bullet to hit it after shooting in one line. The answer should be rounded to 2 digits after decimal point. If the airplane is not hit, then output “Miss!” in one line.

Sample Input
-10 10 2
9
6 9
10 9
10 16
25 16
25 20
10 20
10 27
6 27
-10 18

-10 10 2
9
6 9
10 9
10 16
20 16
20 20
10 20
10 27
6 27
-10 18

0 0 0

Sample Output
2.00
Miss!

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 fpga自动售货机数码管(相关搜索:数字时钟)
    • ¥15 用前端向数据库插入数据,通过debug发现数据能走到后端,但是放行之后就会提示错误
    • ¥15 python天天向上类似问题,但没有清零
    • ¥30 3天&7天&&15天&销量如何统计同一行
    • ¥30 帮我写一段可以读取LD2450数据并计算距离的Arduino代码
    • ¥15 C#调用python代码(python带有库)
    • ¥15 飞机曲面部件如机翼,壁板等具体的孔位模型
    • ¥15 vs2019中数据导出问题
    • ¥20 云服务Linux系统TCP-MSS值修改?
    • ¥20 关于#单片机#的问题:项目:使用模拟iic与ov2640通讯环境:F407问题:读取的ID号总是0xff,自己调了调发现在读从机数据时,SDA线上并未有信号变化(语言-c语言)