hdu1715 (Java) Large number addition

Source: Internet
Author: User

Number of Dafipo

Time limit:1000/1000 MS (java/others) Memory limit:32768/32768 K (java/others)
Total submission (s): 17352 Accepted Submission (s): 5778


The problem Descriptionfibonacci sequence is defined as follows:
F (1) =f (2) =1
F (n) =f (n-1) +f (n-2) n>=3.
Calculates the Fibonacci value of the nth item.

Input inputs The first behavior of an integer n, followed by n behavior integer Pi (1<=pi<=1000).

The output outputs are n lines, and the corresponding F (Pi) for each behavior.

Sample Input512345

Sample Output11235 This is a large number of water problems

Import Java.math.BigDecimal;
Import Java.util.Scanner;
public class Main1715 {
public static void Main (String []args) {
BigDecimal []a=new bigdecimal[1006];
A[0]=new BigDecimal (1);
A[1]=new BigDecimal (1);
for (int i=2;i<1006;i++) {
A[i]=a[i-1].add (A[i-2]);}
Scanner cin=new Scanner (system.in);
while (Cin.hasnext ()) {
int N=cin.nextint ();
for (int j=0;j<n;j++) {
int K=cin.nextint ();
System.out.println (A[k-1]);

}
}

}

}

hdu1715 (Java) Large number addition

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.