import java.io.*; import java.util.*; import java.awt.*; import java.awt.geom.*; import java.text.*; import java.math.*; /** * Solution to Robot Challenge using Dynamic Programming */ class robotchallenge { public Scanner sc; public PrintStream ps; public String toString() { return "robotchallenge"; } /** * The main method */ public void doit() throws Exception { sc = new Scanner( System.in ); // new Scanner( new File( "robotchallenge.judge" ) ); ps = System.out; // new PrintStream( new FileOutputStream( "robotchallenge.solution" ) ); for(;;) { // Read in n, exit if done int n = sc.nextInt(); if( n==0 ) break; // We're going to add 2 points to the input. // The start (0,0) and the end (100,100) n += 2; int xs[] = new int[n]; int ys[] = new int[n]; int penalties[] = new int[n]; // The start will be the first point, with a practically infinite penalty xs[0] = 0; ys[0] = 0; penalties[0] = 1000000000; // Read in the target points for( int i=1; i=0; i-- ) { // Keep a running total of the penalties int penalty = 0; // This is the worst possible value for best[i] best[i] = Double.MAX_VALUE; // What if we go straight from Target Point i to Target Point j? for( int j=i+1; j= best[i] ) break; } } // So, the answer is the best possible score from the start through the course. // We treated the start point (0,0) just like any other point - that means we // figured in stopping there for 1 second. But, that's not right - we shouldn't // stop at the starting spot at all. So, our answer is exactly 1 second too high. ps.printf( "%.3f", best[0]-1.0 ); ps.println(); } } public static Random random = new Random(); public static void shuffle( Point a[] ) { for( int i=0; i=1; y-- ) { snake[k++] = new Point( x+1, y ); } } // Cross walk, crossing the arena as many times as possible Point cross[] = new Point[99*99]; k = 0; int dn = snake.length-1; int up = 0; while( k