hdu 6206 apple 点在内接圆外
//有时间要整理一下 java难道也需要几何板吗?这不是难为人吗?
//http://bbs.csdn.net/topics/60323633
import java.math.BigInteger; import java.util.Scanner; public class Main { public static void debug(BigInteger[] a) { System.out.println(a[0]+" "+a[1]); } public static BigInteger[] getab(BigInteger[] a,BigInteger[] b) { BigInteger[] ab=new BigInteger[2]; ab[0]=b[0].subtract(a[0]);ab[1]=b[1].subtract(a[1]); return ab; }// AB=(x2-x1,y2-y1) public static BigInteger getamulb(BigInteger[] a,BigInteger[] b){ BigInteger ans=a[0].multiply(b[0]); ans=ans.add(a[1].multiply(b[1])); return ans; }//AB*AC=(x2-x1)(x3-x1)+(y2-y1)(y3-y1) public static BigInteger sgn(BigInteger x) {//sgn(x)=(x<0)?-1:((x==0)?0:1); int res=x.compareTo(BigInteger.valueOf(0)); return BigInteger.valueOf(res); } public static BigInteger Fxy(BigInteger[] b,BigInteger[] c,BigInteger[] p) { BigInteger tmp= (p[0].subtract(b[0])).multiply(c[1].subtract(b[1])); return tmp.subtract((p[1].subtract(b[1])).multiply(c[0].subtract(b[0]))); }//f(x,y)=(x-x2)*(y3-y2)-(y-y2)*(x3-x2), public static int getmeow(BigInteger[] a,BigInteger[] b,BigInteger[] c,BigInteger[] d,int flag){ BigInteger[] ab=getab(a,b); BigInteger[] ac=getab(a, c); BigInteger[] db=getab(d, b); BigInteger[] dc=getab(d, c); //System.out.println(getamulb(dc, dc)); //debug(ab);debug(ac);debug(db);debug(dc); BigInteger amb=getamulb(a, b),dmb=getamulb(d, b); BigInteger amc=getamulb(a, c),dmc=getamulb(d, c); BigInteger abac=getamulb(ab, ac),dbdc=getamulb(db, dc); BigInteger l=sgn(abac),r=sgn(dbdc); //System.out.println("1l: "+l+ " r: "+r); l=l.multiply(abac.multiply(abac));r=r.multiply(dbdc.multiply(dbdc)); //System.out.println("2l: "+l+ " r: "+r); l=l.multiply(getamulb(db, db));r=r.multiply(getamulb(ab,ab)); //System.out.println("3l: "+l+ " r: "+r); l=l.multiply(getamulb(dc, dc));r=r.multiply(getamulb(ac,ac)); //flag==1 sgn(AB.AC)*(AB.AC)^2 *|DB|^2 *|DC|^2 > sgn(DB.DC) *(DB.DC)^2 *|AB|^2 *|AC|^2 //flag==0 -sgn(AB.AC)*(AB.AC)^2 *|DB|^2 *|DC|^2 < sgn(DB.DC) *(DB.DC)^2 *|AB|^2 *|AC|^2 //System.out.println("4l: "+l+ " r: "+r+ " flag:"+flag); if(flag==1) { return r.compareTo(l); //l>r } else return (l.add(r)).compareTo(BigInteger.valueOf(0)); //l+r>0 } public static void main(String[] args) { // TODO 自动生成的方法存根 Scanner cin=new Scanner(System.in); BigInteger[][]p=new BigInteger[4][2]; int t=cin.nextInt(); for(int cas=0;cas<t;cas++){ for(int i=0;i<4;i++){ p[i][0]=cin.nextBigInteger(); p[i][1]=cin.nextBigInteger(); } BigInteger fa=Fxy(p[1], p[2], p[0]),fb=Fxy(p[1], p[2], p[3]); BigInteger flg=sgn(fa.multiply(fb)); int flag=flg.compareTo(BigInteger.valueOf(0)); int res=getmeow(p[0],p[1], p[2], p[3], flag); System.out.println(res==1? "Accepted":"Rejected"); } } }