public P67() { timer = new Timer(); timer.start(); // Initialize the matrix we'll use to store the computed values (dynamic // programming implementation) dMatrix = new BigInteger[dimension][dimension]; for (int x = 0; x < dimension; ++x) { for (int y = 0; y < dimension; ++y) { dMatrix[x][y] = BigInteger.valueOf(-1); } } // Load the input matrix matrix = loadMatrix(); // printMatrix(); // Compute the most expensive path through the matrix computePathSum(0, 0); // printMatrix(); // Stop the timer and assign the result to 'answer' timer.stop(); answer = dMatrix[0][0].toString(); }
public P12() { int start = 1; int end = 50000; timer = new Timer(); timer.start(); for (int i = start; i <= end; i++) { int triangleNum = getNthTriangleNumber(i); int numDivisors = getNumberOfDivisors(triangleNum); if (numDivisors >= 500) { answer = triangleNum; divisors = numDivisors; break; } } timer.stop(); }