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 }