First last written yesterday, the fast power of the broken:
(Note: The class name of the public class is main when hdu the problem)
1 ImportJava.util.*;2 Importjava.math.*;3 4 Public classmain{5 Public Static voidMain (string[] args)6 {7 BigInteger a,c,aa,cc;8 intB,d,ans;9Scanner in=NewScanner (system.in);Ten while(In.hasnext ()) One { AAa=NewBigInteger ("1"); -Cc=NewBigInteger ("1"); -A=In.nextbiginteger (); theb=in.nextint (); -C=In.nextbiginteger (); -D=in.nextint (); - if((A.compareto (c) ==1) && (b>d)) +Ans=1; - Else if((A.compareto (c) ==-1) && (b<d)) +Ans=-1; A Else at { - while(b>0) - { - if(b%2!=0) -Aa=aa.multiply (a); -B=b/2; inA=a.multiply (a); - } to while(d>0) + { - if(d%2!=0) theCc=cc.multiply (c); *D=d/2; $C=c.multiply (c);Panax Notoginseng } - the //System.out.println (aa+ "" +cc); +ans=Aa.compareto (cc); A } the if(ans==0) +System.out.println ("="); - Else if(Ans==-1) $System.out.println ("<");//AA<CC $ Else if(ans==1) -System.out.println (">");//AA>CC - } the } -}
Common methods of the BigInteger class:
add:+ subtract:-multiply:* divide:/remainder:% (MoD)
A.pow (b): A^b ABS: Absolute
CompareTo: Compare Size
Min, Max: Take the most value
VALUEOF: Assign an initial value (or use the newbiginteger above)
Reference:
Http://www.cppblog.com/aswmtjdsj/archive/2011/08/20/153973.aspx
Java BigInteger Usage Guide