poj2253 Shortest Way Floyd Frogger

Source: Internet
Author: User

Frogger
Time Limit: 1000MS Memory Limit: 65536K
Total Submissions: 28825 Accepted: 9359

Description

Freddy Frog is sitting on a stone in the middle of a lake. Suddenly he notices Fiona Frog who was sitting on another stone. He plans to visit she, but since the water was dirty and full of tourists ' sunscreen, he wants to avoid swimming and instea D reach her by jumping.
Unfortunately Fiona ' s stone is out of the his jump range. Therefore Freddy considers to use other stones as intermediate stops and reach hers by a sequence of several small jumps.
To execute a given sequence of jumps, a frog's jump range obviously must is at least as long as the longest jump occuring In the sequence.
The frog distance (humans also call it minimax distance) between both stones therefore is defined as the minimum necessary Jump range possible paths between the stones.

You is given the coordinates of Freddy ' s stone, Fiona ' s stone and all other stones in the lake. Your job is to compute the frog distance between Freddy ' s and Fiona ' s stone.

Input

The input would contain one or more test cases. The first line of all test case would contain the number of stones N (2<=n<=200). The next n lines each contain the integers xi,yi (0 <= xi,yi <=) representing the coordinates of stone #i. ston E #1 is Freddy's stone, stone #2 is Fiona's Stone, the other n-2 stones was unoccupied. There ' s a blank line following each test case. Input is terminated by a value of zero (0) for N.

Output

For each test case, print a line saying "Scenario #x" and a line saying "Frog Distance = y" where x was replaced by the TES The T Case number (they was numbered from 1) and Y was replaced by the appropriate real number, printed to three decimals. Put a blank line after all test case, even after the last one.

Sample Input

20 03 4317 419 418 50

Sample Output

Scenario #1Frog Distance = 5.000Scenario #2Frog Distance = 1.414

Source

The coordinates a, B, and other n-2 coordinates of two frogs are given, and any one or two coordinate points are bidirectional connected. Obviously there is at least one path from a to B, and the element of each pathway is the distance between the two points in the pathway, and the distance between them is the maximum distance.

It is now required to find out the maximum distance for all pathways and compare these maximum distances to the minimum maximum distance of a frog.

When the subject output can not be used in%. LF WA took several times here

Must be in%. F

#i

#include <stdio.h> #include <math.h> #include <string.h>double path[201][201];struct node{double x; Double y;}   Que[201];int Main () {int n;   int count=0;        while (scanf ("%d", &n)!=eof) {if (n==0) break;        memset (path,0,sizeof (path));      count++;      for (int i=1;i<=n;i++) {scanf ("%lf%lf", &que[i].x,&que[i].y);            } for (int i=1;i<=n-1;i++) {for (int j=i+1;j<=n;j++) {double tx=que[i].x-que[j].x;            Double ty=que[i].y-que[j].y;        PATH[I][J]=PATH[J][I]=SQRT (Tx*tx+ty*ty);                }} for (int k=1;k<=n;k++) for (int i=1;i<n;i++) for (int j=i+1;j<=n;j++)                        if (Path[i][k]<path[i][j]&&path[k][j]<path[i][j]) if (Path[i][k]<path[k][j])                    PATH[I][J]=PATH[J][I]=PATH[K][J];     else Path[i][j]=path[j][i]=path[i][k];   printf ("Scenario #%d\n", Count); PrintF ("Frog Distance =%.3lf\n", path[1][2]);   printf ("\ n"); } return 0;}

  

poj2253 Shortest Way Floyd Frogger

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.