根据屏幕上的像素做计算的问题,怎么采用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

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问

相似问题

3
我在网上找了个bmp转YUV的程序进行修改,但读不出数据,不知什么问题,有谁懂的请帮忙看下,谢谢了
1
delphi 利用TWICImage类来做图片的像素压缩?
4
unity怎么读取动态加载的图片的像素颜色
5
unity怎么读取动态加载的图片的像素颜色(急!!!另有一个同样问题80c,有用的一起给)
1
手机设备适配的最终呈现是什么效果?请OG大佬出来讲解一下
1
Opencv,imshow打开图片,鼠标放在图片上能自己显示像素值
2
如何调用另一个类的源文件(cpp)中的某个函数的计算结果(变量)?
2
在labview里怎么让程序在调用子VI时是子VI关闭前的状态
1
边缘检测前为什么要用高斯滤波
0
我这儿有个程序,想改程序框标题栏的图标,但是一直都有问题
1
如何减小二值化处理时光强不同带来的影响?
0
一个像素填充的问题的实现,怎么利用C语言解决这个算法的问题
1
python修改了图片像素的RGB后,重新保存,再读取时值没变或者错了
1
有大佬有灰度梯度法亚像素位移计算的matlab程序吗?
1
亚像素精度的数字散斑位移计算的matlab程序
2
android如何获取屏幕正是宽高像素?
0
最近Android面试遇到一道题不会做,还请会做的大神麻烦解答,关于像素透明度减半的问题?
1
图像中的部分图像块进行卷积化为矩阵之后怎么算图像块里每个像素点的梯度MATLAB
1
假设输入的是一幅像素为1K*1K的图像,隐含层有1M个节点,光这一层就有10^12个权重需要训练
2
vs2010 MFC 小数点浮点数与绘图,像素点转化