Java BigInteger Usage Guide

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.