1 import java.io.*;
 2 import java.util.Scanner;
 3 
 4 class firefly {
 5 
 6   public static void main( String[] args ) throws Exception {
 7     String inFile = args.length > 0 ? args[0] : "firefly.in";
 8     Scanner in = new Scanner( new File( inFile ) );
 9     double s = in.nextInt(); // my speed
10     double x = in.nextInt(); // my x
11     double y = in.nextInt(); // my y
12     int n = 0;
13 
14     while ( s > 0 ) {
15       n++;
16       int fx = in.nextInt(); // firefly x
17       int fy = in.nextInt(); // firefly y
18       boolean caught = false;
19       while ( fx >= 0 ) {
20         double d = Math.sqrt( (fx-x)*(fx-x) + (fy-y)*(fy-y) );
21         if ( d - s <= 1 && !caught ) {
22           System.out.format( "Firefly %d caught at (%d,%d)%n", n, fx, fy );
23           caught = true;
24           /* sanity check */ if ( d - s > 0.999 ) System.err.format( "Borderline! D=%f%n", d - s );
25         }
26         else if ( !caught ) {
27           x = x + s/d * (fx-x);
28           y = y + s/d * (fy-y);
29         }
30         fx = in.nextInt();
31         fy = in.nextInt();
32       }
33       if ( !caught ) {
34         System.out.format( "Firefly %d not caught%n", n );
35       }
36       s = in.nextDouble();
37       x = in.nextInt();
38       y = in.nextInt();
39     }
40   }
41 
42 }