您的位置:首页 > 其它

hdu1245 Saving James Bond

2016-05-05 17:15 288 查看
Problem Description

This time let us consider the situation in the movie "Live and Let Die" in which James Bond, the world's most famous spy, was captured by a group of drug dealers. He was sent to a small piece of land at the center of a lake filled with crocodiles. There he
performed the most daring action to escape -- he jumped onto the head of the nearest crocodile! Before the animal realized what was happening, James jumped again onto the next big head... Finally he reached the bank before the last crocodile could bite him
(actually the stunt man was caught by the big mouth and barely escaped with his extra thick boot).

Assume that the lake is a 100×100 square one. Assume that the center of the lake is at (0,0) and the northeast corner at (50,50). The central island is a disk centered at (0,0) with the diameter of 15. A number of crocodiles are in the lake at various positions.
Given the coordinates of each crocodile and the distance that James could jump, you must tell him whether he could escape.If he could,tell him the shortest length he has to jump and the min-steps he has to jump for shortest length.

 

Input

The input consists of several test cases. Each case starts with a line containing n <= 100, the number of crocodiles, and d > 0, the distance that James could jump. Then one line follows for each crocodile, containing the (x, y) location of the crocodile. Note
that x and y are both integers, and no two crocodiles are staying at the same position. 

 

Output

For each test case, if James can escape, output in one line the shortest length he has to jump and the min-steps he has to jump for shortest length. If it is impossible for James to escape that way, simply ouput "can't be saved".

题解

先算出每一天鳄鱼之间的距离

(sqrt(sqr(b[i]-b[j])+sqr(c[i]-c[j])))

即找一条从起点到终点的最短路。(由于数据只有100,我用了FLOYED)

for k:=1 to n do

  for i:=1 to n do

    for j:=1 to n do

      if (j<>k)and(a[i,k]+a[k,j]<a[i,j]) then

        a[i,j]:=a[i,k]+a[k,j];
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  最短路 hdu 1245