|
|
back to boardFor some reason I kept getting run time error at 1. Help plz? import java.util.*; class Path { //Fields public int X; public int Y; private int MaxPath; //Constructor public Path(int x, int y) { this.X = x; this.Y = y; this.MaxPath = 0; } //Methods public int getMaxPath(List<Path> pathList) { if (this.MaxPath != 0) { return this.MaxPath; } int max = 0; for (Path p : pathList) { if ((p.X > this.X) && (p.Y > this.Y)) { int subMaxPath = p.getMaxPath(pathList); if (max < subMaxPath) { max = subMaxPath; } } } this.MaxPath = max + 1; return this.MaxPath; } } public class Main { /** * @param args the command line arguments */ public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int N = scanner.nextInt(); int M = scanner.nextInt(); int K = scanner.nextInt(); List<Path> pathList = new ArrayList<Path>(); for (int i = 0; i < K; i++) { pathList.add(new Path(scanner.nextInt(), scanner.nextInt())); } int max = 0; for (Path p : pathList) { int curTrend = p.getMaxPath(pathList); if (curTrend > max) { max = curTrend; } } System.out.format("%.0f", 100 * (N + M) - 100 * max * (2 - Math.sqrt(2))); } } It works fine on my computer. Am I using a different version of Java? Re: For some reason I kept getting run time error at 1. Help plz? Posted by SVVS 15 Apr 2014 00:27 after output data need end of line! Re: For some reason I kept getting run time error at 1. Help plz? I'm having the same problem when I use JAVA :-( |
|
|