标签:frame UI logs each mem highlight contains add scan
Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Others)
Total Submission(s): 806 Accepted Submission(s): 267
3 -2 0 0 -2 2 0 2 -2 -2 0 0 -2 2 0 0 2 -2 0 0 -2 2 0 1 1
Accepted Rejected Rejected
只需要输入三个点的坐标即可 p1(x1,y1) p2(x2,y2) p3(x3,y3) A=x1*x1+y1*y1 B=x2*x2+y2*y2 C=x3*x3+y3*y3 G=(y3-y2)*x1+(y1-y3)*x2+(y2-y1)*x3 X=((B-C)*y1+(C-A)*y2+(A-B)*y3)/(2*G) Y=((C-B)*x1+(A-C)*x2+(B-A)*x3)/(2*G)
import java.math.BigDecimal; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner cin=new Scanner(System.in); BigDecimal A,B,C,G; BigDecimal x1,x2,x3,y1,y2,y3,x0,y0; BigDecimal X,Y; int t; t=cin.nextInt(); while(t-->0) { x1=cin.nextBigDecimal(); y1=cin.nextBigDecimal(); x2=cin.nextBigDecimal(); y2=cin.nextBigDecimal(); x3=cin.nextBigDecimal(); y3=cin.nextBigDecimal(); x0=cin.nextBigDecimal(); y0=cin.nextBigDecimal(); A=x1.multiply(x1).add(y1.multiply(y1)); B=x2.multiply(x2).add(y2.multiply(y2)); C=x3.multiply(x3).add(y3.multiply(y3)); G=BigDecimal.valueOf(1); G=y3.subtract(y2).multiply(x1).add(y1.subtract(y3).multiply(x2)).add(y2.subtract(y1).multiply(x3)); X=B.subtract(C).multiply(y1).add(C.subtract(A).multiply(y2)).add(A.subtract(B).multiply(y3)).divide(BigDecimal.valueOf(2)); Y=C.subtract(B).multiply(x1).add(A.subtract(C).multiply(x2)).add(B.subtract(A).multiply(x3)).divide(BigDecimal.valueOf(2)); x0=x0.multiply(G); y0=y0.multiply(G); x1=x1.multiply(G); y1=y1.multiply(G); BigDecimal a=x0.subtract(X).multiply(x0.subtract(X)).add( y0.subtract(Y).multiply(y0.subtract(Y))); BigDecimal b=x1.subtract(X).multiply(x1.subtract(X)).add( y1.subtract(Y).multiply(y1.subtract(Y))); if(a.compareTo(b)>0) System.out.println("Accepted"); else System.out.println("Rejected"); } } }
标签:frame UI logs each mem highlight contains add scan
原文地址:http://www.cnblogs.com/--lr/p/7587275.html