import java.io.*; import java.util.*; import java.awt.geom.*; /** * Solution to Cake Cutting * * Here's the key: Every line that crosses the circle creates one new section. * Every time a line crosses another line inside the circle, it creates one new section. * So, we've just got to count the number of lines that cross the circle * and the number of line intersections that are inside the circle. * * @author vanb */ public class cake_vanb { public Scanner sc; public PrintStream ps; /** * A Line, defined by two points. * * @author vanb */ public class Line { /** (x1,y1) and (x2,y2) */ public int x1, y1, x2, y2; /** * Create a Line. * * @param x1 X coord of first point * @param y1 Y coord of first point * @param x2 X coord of second point * @param y2 Y coors of second point */ public Line( int x1, int y1, int x2, int y2 ) { this.x1 = x1; this.y1 = y1; this.x2 = x2; this.y2 = y2; } public String toString() { return "(" + x1 + "," + y1 + ") - (" + x2 + "," + y2 + ")"; } } /** * Driver. * @throws Exception */ public void doit() throws Exception { sc = new Scanner( System.in ); //new File( "cake.judge" ) ); ps = System.out; //new PrintStream( new FileOutputStream( "cake.solution" ) ); List lines = new LinkedList(); HashSet points = new HashSet(); int testcase = 0; for(;;) { double r = sc.nextDouble(); double xc = sc.nextDouble(); double yc = sc.nextDouble(); int n = sc.nextInt(); if( r<0.5 ) break; ++testcase; // We always start with 1 - that's the circle itself int count = 1; lines.clear(); for( int i=0; i