hdoj-1715-大菲波数(大斐波那契数列)

题目链接

 1 import java.util.*;
 2 import java.math.*;
 3 public class Main{
 4 
 5     public static void main(String[] args) {
 6         final int MAXN = 1005;
 7         BigInteger nums[] = new BigInteger[1005];
 8         nums[1] = BigInteger.ONE;
 9         nums[2] = BigInteger.valueOf(1);
10         nums[3] = BigInteger.valueOf(2);
11         for (int i=4; i<MAXN; i++) {
12             nums[i] = nums[i-2].add(nums[i-1]);
13         }
14         Scanner cin = new Scanner(System.in);
15         int t = cin.nextInt();
16         
17         while (t-- > 0) {
18             int a = cin.nextInt();
19             System.out.println(nums[a]);
20         }
21     }
22 } 

 

posted @ 2018-05-02 10:27  朤尧  阅读(371)  评论(0编辑  收藏  举报