Click to open Hangzhou electric 1715
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 Input
512345
Sample Output
11235
Code implementation:
Import java.math.biginteger;import java.util.scanner;class main{public static void Main (String args[]) {biginteger[] p= New biginteger[1005];p [0]=new BigInteger ("1");p [1]=new BigInteger ("1"); for (int i=2;i<1005;i++) {P[i]=p[i-1].add ( P[i-2]);} Scanner sc=new Scanner (system.in); int n=sc.nextint (); while (n-->0) {int pi=sc.nextint (); System.out.println (P[pi-1]);}}
Hangzhou Electric 1715 (Dafipo number)