hdu 6206 apple 點在內接圓外

來源:互聯網
上載者:User

標籤:import   util   i++   div   產生   ati   cte   integer   pre   

//有時間要整理一下 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");                                                        }}}

 

hdu 6206 apple 點在內接圓外

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.