题意
给出三个圆上的点,和一个目标的点,问目标点是否在这三个点构成的圆外面。
思路
许久没见过的Java高精度,不要加package!!!
import java.math.BigDecimal;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int t = scan.nextInt();
while(t > 0) {
t--;
Point a = new Point(), b = new Point(), c = new Point(), tar = new Point();
a.x = scan.nextBigDecimal();
a.y = scan.nextBigDecimal();
b.x = scan.nextBigDecimal();
b.y = scan.nextBigDecimal();
c.x = scan.nextBigDecimal();
c.y = scan.nextBigDecimal();
tar.x = scan.nextBigDecimal();
tar.y = scan.nextBigDecimal();
Point zhong = new Point();
zhong.Waixin(a, b, c);
// System.out.println("zhongx : " + zhong.x + ", zhongy : " + zhong.y);
// System.out.println("tarx : " + tar.x + ", tary : " + tar.y);
BigDecimal d1 = zhong.Cal(tar, zhong); // 目标点和圆心距离
BigDecimal d2 = zhong.Cal(a, zhong); // 半径
// System.out.println("d1 : " + d1 + "\n" + "d2 : " + d2);
if(d1.compareTo(d2) != 1) System.out.println("Rejected");
else System.out.println("Accepted");
}
}
}
class Point {
public BigDecimal x;
public BigDecimal y;
void Waixin (Point a, Point b, Point c) {
BigDecimal two = new BigDecimal(2);
BigDecimal a1 = b.x.subtract(a.x), b1 = b.y.subtract(a.y);
BigDecimal aa1 = a1.multiply(a1);
BigDecimal bb1 = b1.multiply(b1);
BigDecimal cc1 = aa1.add(bb1);
BigDecimal c1 = aa1.add(bb1);
c1 = c1.divide(two);
BigDecimal a2 = c.x.subtract(a.x), b2 = c.y.subtract(a.y);
BigDecimal aa2 = a2.multiply(a2);
BigDecimal bb2 = b2.multiply(b2);
BigDecimal c2 = aa2.add(bb2);
c2 = c2.divide(two);
BigDecimal d1 = a1.multiply(b2);
BigDecimal d2 = a2.multiply(b1);
BigDecimal d = d1.subtract(d2);
BigDecimal qq = c1.multiply(b2), ww = c2.multiply(b1), ee = a1.multiply(c2), rr = a2.multiply(c1);
BigDecimal ii = qq.subtract(ww), jj = ee.subtract(rr);
ii = ii.divide(d);
jj = jj.divide(d);
this.x = a.x.add(ii);
this.y = a.y.add(jj);
}
BigDecimal Cal(Point a, Point b) {
BigDecimal xx = a.x.subtract(b.x), yy = a.y.subtract(b.y);
xx = xx.multiply(xx);
yy = yy.multiply(yy);
xx = xx.add(yy);
return xx;
}
}