Is there any time to tidy up Java? Does it need a geometry board? Isn't that a tough one?
http://bbs.csdn.net/topics/60323633
import Java.math.biginteger;import Java.util.Scanner; Public classMain { Public Static voidDebug (biginteger[] a) {System. out. println (a[0]+" "+a[1]); } Public Staticbiginteger[] Getab (biginteger[] a,biginteger[] b) {biginteger[] ab=Newbiginteger[2]; ab[0]=b[0].subtract (a[0]); ab[1]=b[1].subtract (a[1]); returnAB; }//ab= (x2-x1,y2-y1) Public StaticBigInteger getamulb (biginteger[] a,biginteger[] b) {BigInteger ans=a[0].multiply (b[0]); Ans=ans.add (a[1].multiply (b[1])); returnans; }//ab*ac= (x2-x1) (x3-x1) + (y2-y1) (y3-y1) Public StaticBigInteger sgn (BigInteger x) {//sgn (x) = (x<0)-1: ((x==0)? 0:1); intRes=x.compareto (Biginteger.valueof (0)); returnbiginteger.valueof (RES); } Public StaticBigInteger Fxy (biginteger[] b,biginteger[] c,biginteger[] p) {BigInteger tmp= (p[0].subtract (b[0]). Multiply (c[1].subtract (b[1])); returnTmp.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 intGetmeow (biginteger[] a,biginteger[] b,biginteger[] c,biginteger[] D,intflag) {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);d ebug (AC);d ebug (db);d Ebug (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) { returnR.compareto (l);//L>r } Else return(L.add (R)). CompareTo (Biginteger.valueof (0));//l+r>0 } Public Static voidMain (string[] args) {//TODO Auto-generated method stubsScanner cin=NewScanner (System.inch); Biginteger[][]p=Newbiginteger[4][2]; intt=Cin.nextint (); for(intcas=0; cas<t;cas++){ for(intI=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)); intFlag=flg.compareto (Biginteger.valueof (0)); intRes=getmeow (p[0],p[1], p[2], p[3], flag); System. out. println (res==1?"Accepted":"rejected"); }}}
Hdu 6206 Apple dots inside the circle