Nyoj large number of classes summary (Java)

Source: Internet
Author: User

Board Overlay

Title Link: http://acm.nyist.net/JudgeOnline/problem.php?pid=45

Sample input
3123
Sample output
1521

The code is as follows:

Import Java.io.*;import java.util.*;import Java.math.bigdecimal;import java.math.biginteger;// Declaration BigInteger large Number class public class main{public    static void Main (String args[])    {        Scanner cin = new Scanner ( system.in);        int T=cin.nextint ();        while (t-->0)        {        int n;        N=cin.nextint ();        BigInteger a=biginteger.valueof (4);        for (int i=1; i<n; ++i)        a=a.multiply (biginteger.valueof (4));        System.out.println (A.subtract (biginteger.valueof (1)). Divide (biginteger.valueof (3));}}}    

Compare size

Title Link: http://acm.nyist.net/JudgeOnline/problem.php?pid=73

Sample input
111111111111111111111111111 88888888888888888888-1111111111111111111111111  222222220 0
Sample output
A>ba<b

The code is as follows:

Import Java.io.*;import java.util.*;import Java.math.bigdecimal;import java.math.biginteger;// Declaration BigInteger large Number class public class main{public    static void Main (String args[])    {        Scanner cin = new Scanner ( system.in);        while (Cin.hasnext ())        {        BigInteger a=cin.nextbiginteger ();        BigInteger B=cin.nextbiginteger ();        BigInteger Zero=biginteger.zero;        if (A.compareto (zero) ==0&&b.compareto (zero) ==0) break;        int F=a.compareto (b);        if (f==-1)        System.out.println ("a<b");        else if (f==0)        System.out.println ("a==b");        else         System.out.println ("A>b");}}}    

Recursive value

Title Link: http://acm.nyist.net/JudgeOnline/problem.php?pid=114

Sample input
1 1 1
Sample output
69087442470169316923566147

The code is as follows:

Import Java.io.*;import java.util.*;import Java.math.bigdecimal;import java.math.biginteger;// Declaration BigInteger large Number class public class main{public    static void Main (String args[])    {        Scanner cin = new Scanner ( system.in);        BigInteger fac[]=new biginteger[100];        while (Cin.hasnext ())        {for        (int i=0; i<=2; ++i)        Fac[i]=cin.nextbiginteger ();        for (int i=3; i<=99; ++i)        Fac[i]=fac[i-1].add (Fac[i-2]). Add (fac[i-3]);        System.out.println (fac[99]);}}    


Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Nyoj large number of classes summary (Java)

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.