# kokx/tue-2io21

Fixed running errors.

1 parent 6a825f5 commit 58a767bb95e2f534b734187ff1d1f708bd227b27 committed May 8, 2012
 @@ -1,6 +1,8 @@ import java.io.*; import java.util.*; +import model.*; + class Main { Scanner sc;
 @@ -3,6 +3,8 @@ import java.io.*; import java.util.*; +import model.*; + public abstract class Algorithm { @@ -21,7 +23,7 @@ public Algorithm(Field field) /** * Run the algorithm. */ - public abstract void run() + public abstract void run(); /** * Determine the distance between sourcePoint and destPoint. @@ -31,17 +33,16 @@ public abstract void run() * @param m 2 = Euclidean, 1 = Manhatten * @return Distance from sourcePoint to destPoint */ - public int Distance(Point sourcePoint, Point destPoint, int m) { + public double Distance(Point sourcePoint, Point destPoint, int m) + { + long dx = (long) Math.abs(destPoint.getX() - sourcePoint.getX()); + long dy = (long) Math.abs(destPoint.getY() - sourcePoint.getY()); + switch (m) { case 1: - return Math.abs(destPoint.getX() - sourcePoint.getX()) - + Math.abs(destPoint.getY() - sourcePoint.getY()); - break; - case 2: - return Math.sqrt(Math.pow(Math.abs(destPoint.getX() - sourcePoint.getX()), 2) - + Math.pow(Math.abs(destPoint.getY() - sourcePoint.getY()), 2)); - break; + return (double) (dx + dy); + default: + return Math.pow(Math.pow(dx, m) + Math.pow(dy, m), 1.0/m); } } - }
 @@ -3,10 +3,22 @@ import java.io.*; import java.util.*; +import model.*; + public class DeLiClu extends Algorithm { - void run() + /** + * Constructor. + * + * @param field + */ + public DeLiClu(Field field) + { + super(field); + } + + public void run() { // magic }
 @@ -3,6 +3,8 @@ import java.io.*; import java.util.*; +import model.*; + class Generator { public final static int DEFAULT_MAX_OFFSET = 100000;
 @@ -3,6 +3,8 @@ import java.io.*; import java.util.*; +import model.*; + class Main { Scanner sc;
 @@ -47,7 +47,7 @@ public Point getCentroid() { long totalx = 0; long totaly = 0; - for (Point point : pointList) { + for (Point point : points) { totalx += point.getX(); totaly += point.getY(); }