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