Description John Doe, a skilled pilot, enjoys traveling. while on vacation, he rents a small plane and starts visiting beautiful places. to save money, John must determine the shortest closed tour that connects his destinations. each destination is represented by a point in the plane pi = <xi, yi>. john uses the following strategy: he starts from the leftmost point, then he goes strictly left to right to the rightmost point, and then he goes strictly right back to the starting point. it is known that the points have distinct x-coordinates. Write a program that, given a set of n points in the plane, computes the shortest closed tour that connects the points according to John's strategy.Input The program input is from a text file. each data set in the file stands for a participant set of points. for each set of points the data set contains the number of points, and the point coordinates in ascending order of the x coordinate. white spaces can occur freely in input. the input data are correct.Output For each set of data, your program shocould print the result to the standard output from the beginning of a line. the tour length, a floating-point number with two fractional digits, represents the result. an input/output sample is in the table below. here there are two data sets. the first one contains 3 points specified by their x and y coordinates. the second point, for example, has the x coordinate 2, and the y coordinate 3. the result for each data set is the tour length, (6.47 for the first data set in the given example ).Sample Input 31 12 33 141 12 33 14 2 Sample Output 6.477.89
It's a classic problem. The coordinates of n points on the given plane (in ascending order of x ), Your task is to design a route from the leftmost to the rightmost and then return to the leftmost, exactly once every point. Minimum cost. It can be seen that two people start from the leftmost end at the same time. The minimum cost of one person passing through each vertex. # Include
# Include
# Include
# Include
# Include
Typedef long LL; using namespace std; const int maxn = 110; double x [maxn], y [maxn]; double dp [maxn] [maxn]; double dis (int I, int j) {return sqrt (x [I]-x [j]) * (x [I]-x [j]) + (y [I]-y [j]) * (y [I]-y [j]);} int main () {int n; while (~ Scanf ("% d", & n) {for (int I = 0; I
|