/* Sample solution for NCPC 2006: Tour Guide * Author: Truls A. Bjoerklund * * This is a generalization of TSP. We hence try all permutations * and choose the best one. A second degree polynomial equation has * to be solved to be able to find the time when the guide will meet * a particular tourist. */ import java.io.*; import java.lang.*; public class tourguide_tab { //Solving a second degree polynomial equation public static double timeToMeet(double gx, double gy, double gv, double x, double y, double vx, double vy){ double a=vx*vx+vy*vy-gv*gv; double b = 2*(vx*(x-gx)+vy*(y-gy)); double c = (x-gx)*(x-gx)+(y-gy)*(y-gy); return (-b - Math.sqrt(b*b - 4*a*c))/(2*a); } public static void main(String[] args) throws Exception{ BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); int n = Integer.parseInt(in.readLine()); while(n!=0){ double v = Double.parseDouble(in.readLine()); double[][] retards = new double[n][5]; for(int i=0;imaxtime)maxtime=newt; } if(maxtime a[j+1]) { j--; if(j==-1) return null; } int k = a.length - 1; while (a[j] > a[k]) k--; temp = a[k]; a[k] = a[j]; a[j] = temp; int r = a.length - 1; int s = j + 1; while (r > s) { temp = a[s]; a[s] = a[r]; a[r] = temp; r--; s++; } return a; } }