编程介的小学生 2019-05-21 17:59 采纳率: 20.5%
浏览 235

计算时间间隔的一个算法的求解问题,怎么利用C语言的程序代码编写的方式实现这个程序的计算的?

Problem Description
“JezzBall is a computer game in which red-and-white ‘atoms’ bounce about a rectangular field of play. The player advances to later levels (with correspondingly higher numbers of atoms and lives) by containing the atoms in progressively smaller spaces, until at least 75% of the area is blocked off.” (wikipedia.org)
The picture to the right is a screenshot from the original game, where the player has already covered some space (the black part). In this problem we will consider a slightly different, non-discrete, version of the game. That is, while the length unit is still pixels, you should treat them as non-discrete in the sense that all objects can be at non-integer coordinates and all movements are continuous.

The size of the playing field will be 1024 × 768 pixels. The atoms that bounce around will be infinitely thin (and not round balls like in the screenshot). The atoms will move at a constant speed and only change direction when hitting the edge of the playing field (x-coordinate 0 and 1024 or y-coordinate 0 and 768), where they bounce without loss of energy. The atoms do not hit each other.

The player can divide the playing field in two by shooting a horizontal or vertical ray from (in this problem) a fixed point on the playing field. The ray will then extend in both directions simultaneously (up and down for vertical rays, or left and right for horizontal rays) at a uniform speed (in this problem always 200 pixels per second). The rays will also be infinitely thin. If no atom touches any part of the ray while it’s still being extended, the field has successfully been divided. Otherwise the player loses a life.

If an atom touches the endpoint of an extending edge, this will not be counted as a hit. Also, if an atom hits the ray at the same instant it has finished extending, this will also not count as a hit. Write a program that determines the minimum time the player must wait before he can start extending a ray so that an atom will not hit it before the ray has been completed.

Input
Each test case starts with a line containing a single integer n, the number of atoms (1 ≤ n ≤ 10). Then follows a line containing two integers, x and y, the position where the two ray ends will start extending from (0 < x < 1024, 0 < y < 768). Then n lines follow, each containing four integers, x, y, vx and vy describing the initial position and speed of an atom (0 < x < 1024, 0 < y < 768, 1 ≤ |vx| ≤ 200, 1 ≤ |vy| ≤ 200). The speed of the atom in the x direction is given by vx, and the speed in the y direction is given by vy. All positions in each input will be distinct. The input is terminated by a case where n = 0, which should not be processed. There will be at most 25 test cases.

Output
For each test case, output the minimum time (with exactly 5 decimal digits) until the player can extend either a horizontal or vertical ray without an atom colliding with it while it is being drawn. The input will be constructed so that the first time this occurs will be during an open interval at least 10-5 seconds long. If no such interval is found during the first 10000 seconds, output “Never” (without quotes).

Sample Input
3
700 420
360 290 170 44
900 150 -53 20
890 100 130 -100
4
10 10
1 1 192 144
513 385 192 144
1023 767 -192 -144
511 383 -192 -144
0

Sample Output
2.80094
Never

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

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