编程介的小学生 2019-04-11 20:05 采纳率: 20.5%
浏览 157

带头的节点的指针数组在搜索问题里的运用,怎么使用C语言的程序的设计的方式来实现的

Problem Description
Traveling through hyperspace is a risky thing, considering the fact that there are many stars, asteroids, (and possibly black holes!) out in the galaxy, and without careful planning, it’s so easy to end up thousands of light-years from your planned destination. Therefore people who don’t like uncertainty tend to avoid hyperspace traveling. However, as we need to travel through an unknown sector to attend the ACM/ICPC world final in the year 3007, and you’re the most experienced navigator and programmer we can find, it is unfortunately your responsibility to plan a journey that will lead us across the sector.

It is know that there are several strange asteroids in the sector – every one of them is generating gravity anomaly in a circular area with a fixed radius around the asteroid. One particular position’s abnormality value is equal to the number of asteroids affecting that position.

You decided that you will follow one simple rule during your travel – that is, you will always fly your ship along the gravity range boundary of one or more asteroids. Nevertheless, the possibility of failure remains due to the unpredictable nature of gravity anomaly, therefore you also want to minimize the absolute difference between the maximum abnormality value and the minimum abnormality value on your flight path. For simplicity, you can assume that all asteroids (as well as your flight path) will be on the plane Z = 0. Can you find the minimum absolute value with the help of your computer?

Input
There are multiple test cases in the input file. Each test case starts with one integer N (2 <= N <= 30), the number of asteroids in the sector, followed by four real numbers, Sx, Sy, Tx, Ty, representing the x-coordinate and y-coordinate of your current position and your destination. Each of the following N lines consists of three real numbers X, Y and R (R >= 1), indicating that there is an asteroid at position (X, Y) with gravity range R.

There is a blank line after each test case. N = 0 indicates the end of input file and should not be processed by your program.

It is guaranteed that the input data is always legal, i.e. both your starting position and your destination are on the boundary of one or more asteroids, no two asteroids will have the same position, every real number in the input file has at most three digits after the decimal point, and the absolute value of any real number does not exceed 10000.

Output
For each test case, output one integer on one separate line as requested. If there is no way for you to reach the destination by only flying along asteroids’ gravity range boundaries, output -1 instead.

Sample Input
2
-1.000 0.000 1.000 0.000
0.000 0.000 1.000
1.000 0.000 1.000

2
-1.000 0.000 5.000 0.000
-1.000 -1.000 1.000
4.000 0.000 1.000

0

Sample Output
Case 1: 1
Case 2: -1

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥60 版本过低apk如何修改可以兼容新的安卓系统
    • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
    • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
    • ¥50 有数据,怎么用matlab求全要素生产率
    • ¥15 TI的insta-spin例程
    • ¥15 完成下列问题完成下列问题
    • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
    • ¥15 YoloV5 第三方库的版本对照问题
    • ¥15 请完成下列相关问题!
    • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?