Problem:
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});

Circles Intersection

You are given circle $A$ with radius $r_a$ and with central coordinate $(x_a, y_a)$ and circle $B$ with radius $r_b$ and with central coordinate $(x_b, y_b)$.

Write a program which prints:

"2" if $B$ is in $A$,

"-2" if $A$ is in $B$,

"1" if circumference of $A$ and $B$ intersect, and

"0" if $A$ and $B$ do not overlap.

You may assume that $A$ and $B$ are not identical.

Input

The input consists of multiple datasets. The first line consists of an integer $N$ ($N \leq 50$), the number of datasets. There will be $N$ lines where each line represents each dataset. Each data set consists of real numbers:

$x_a$ $y_a$ $r_a$ $x_b$ $y_b$ $r_b$

Output

For each dataset, print 2, -2, 1, or 0 in a line.

Sample Input

2
0.0 0.0 5.0 0.0 0.0 4.0
0.0 0.0 2.0 4.1 0.0 2.0

Output for the Sample Input

2
0

Solution in JAVA (judge verdict: Wrong Answer)

import java.io.IOException;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

import static java.lang.Double.isNaN;
import static java.lang.StrictMath.sqrt;
import static jdk.nashorn.internal.runtime.ScriptRuntime.EQ;

/**
 */
class Main {
	public static void main(String[] args) throws IOException {
		Scanner in = new Scanner(System.in);

		int n = in.nextInt();
		for(int i=0;i<n;i++) {
			Point pa = new Point(in.nextDouble(), in.nextDouble());
			double ra = in.nextDouble();
			Point pb = new Point(in.nextDouble(), in.nextDouble());
			double rb = in.nextDouble();

			Circle ca = new Circle(pa, ra);
			Circle cb = new Circle(pb, rb);

			int ans = CircleUtil.calcIntersection(ca, cb);

			System.out.println(ans);
		}
	}
}

class CircleUtil {
	private static final double EPS = 1e-10;

	/**
	 * ???????????????????????????
	 * @param ca
	 * @param cb
	 * @return 2: cb???ca??????????????? -2: ca???cb??????????????? 1: ca??¨cb?????????????????????(???????????????????????????), 0: ?????????????????????????????????????????????
	 */
	public static int calcIntersection(Circle ca, Circle cb) {
		double r = PointUtil.dist(ca.getCenter(), cb.getCenter());
		double ra = ca.getR();
		double rb = cb.getR();
		if(r > (ra+rb)) {
			return 0; // no cross
		}

		if(EQ(r, 0.0)) {
			if(ra < rb) {
				return -2;
			}
			return 2;
		}

		if(r < Math.abs(rb - 2*ra)) {
			return -2;
		}

		if(r < Math.abs(ra - 2*rb)) {
			return 2;
		}

		return 1; // cross
	}

	public static void swap(Point a, Point b) {
		double tx = a.x, ty = a.y;
		a.x = b.x; a.y = b.y;
		b.x = tx; b.y = ty;
	}

	public static void swapXY(Point p1) {
		double buf = p1.getX();
		p1.x = p1.y;
		p1.y = buf;
	}
}

class Circle {
	Point center;
	double r;

	public Circle(Point center, double r) {
		this.center = center;
		this.r = r;
	}

	public Point getCenter() {
		return center;
	}

	public void setCenter(Point center) {
		this.center = center;
	}

	public double getR() {
		return r;
	}

	public void setR(double r) {
		this.r = r;
	}
}

class Point {
	double x;
	double y;

	public Point(double x, double y) {
		this.x = x;
		this.y = y;
	}

	public Point getMinus(Point p2) {
		double sx = this.x - p2.getX();
		double sy = this.y - p2.getY();
		return new Point(sx,sy);
	}

	public double len() {
		return x*x + y*y;
	}

	public double getX() {
		return x;
	}

	public void setX(double x) {
		this.x = x;
	}

	public double getY() {
		return y;
	}

	public void setY(double y) {
		this.y = y;
	}
}

class PointUtil {
	public static double EPS = 1e-10;

	public static double dist(Point p1, Point p2) {
		return Math.sqrt(Math.pow(p2.getX() - p1.getX(), 2.0) + Math.pow(p2.getY() - p1.getY(), 2.0));
	}

	/**
	 * angle of vec(p1-p) and vec(p2-p)
	 * @param p1
	 * @param p2
	 * @return
	 */
	public static double angleRad(Point p1, Point p2, Point p) {
		double a1 = p1.getX() - p.getX();
		double a2 = p1.getY() - p.getY();
		double b1 = p2.getX() - p.getX();
		double b2 = p2.getY() - p.getY();

		return Math.acos((a1*b1+a2*b2) / ( Math.sqrt(a1*a1 + a2*a2) * Math.sqrt(b1*b1 + b2*b2)));
	}

	public static boolean isParallel(Point a1, Point a2, Point b1, Point b2) {
		return EQ(cross(a1.getMinus(a2), b1.getMinus(b2)), 0.0);
	}

	public static double cross(Point a, Point b) {
		return a.getX()*b.getY() - a.getY()*b.getX();
	}

	public static boolean EQ(double left, double right) {
		if(Math.abs(left - right) <= EPS) {
			return true;
		}
		return false;
	}
}