HDU 1715大数

View Code
 1 import java.util.*;
 2 import java.math.*;
 3 import java.io.*;
 4 
 5 public class Main{
 6   public static void main(String args[]){
 7    BigInteger f[] = new BigInteger[1005];
 8    int n, p;
 9    Scanner cin = new Scanner(System.in);
10    f[1] = BigInteger.valueOf(1);
11    f[2] = BigInteger.valueOf(1);
12    
13    for(int i=3; i<1005; i++){
14     f[i] = f[i-1].add(f[i-2]);
15    }
16    
17    n = cin.nextInt();
18    for(int i=0; i<n; i++)
19    {
20       p = cin.nextInt();
21       System.out.println(f[p]);
22     } 
23        
24   }
25   
26 }
posted @ 2012-09-04 19:20  zhongya  阅读(164)  评论(0编辑  收藏  举报