/**************************************************************
 * Find numbers that are the sum of two cubes in two different ways
 * Mark Goadrich
 * CSC 204 - Spring 2008
 **************************************************************/
public class Taxi{

    // main method to run the program
    public static void main(String[] args) {
        
        // get number N, max size of internal numbers, from user
        double N = Double.parseDouble(args[0]);
	
	// find all combinations of four distinct numbers
	for (int a = 0; a < N; a++) {
	    for (int b = a + 1; b < N; b++) {
		for (int c = b + 1; c < N; c++) {
		    for (int d = c + 1; d < N; d++) {
			if (Math.pow(a, 3) + Math.pow(b, 3) ==
			    Math.pow(c, 3) + Math.pow(d, 3)) {
			    System.out.println(Math.pow(a, 3) +
					       Math.pow(b, 3));
			    System.out.println("" + a + "," + b + "," + 
					       c + "," + d);
			}
			if (Math.pow(a, 3) + Math.pow(c, 3) ==
			    Math.pow(b, 3) + Math.pow(d, 3)) {
			    System.out.println(Math.pow(a, 3) +
					       Math.pow(c, 3));
			    System.out.println("" + a + "," + b + "," + 
					       c + "," + d);
			}
			if (Math.pow(a, 3) + Math.pow(d, 3) ==
			    Math.pow(c, 3) + Math.pow(b, 3)) {
			    System.out.println(Math.pow(a, 3) +
					       Math.pow(d, 3));
			    System.out.println("" + a + "," + b + "," + 
					       c + "," + d);
			}
		    }
		}
	    }
	}
    }
}

