hdu 1715 大菲波数

http://acm.hdu.edu.cn/showproblem.php?pid=1715

View Code
 1 import java.math.BigInteger;
 2 import java.util.Scanner;
 3 
 4 
 5 public class Main {
 6     public static void main(String[] args) {
 7         BigInteger f[]=new BigInteger[1010];
 8         int a[]=new int[1010];
 9         Scanner cinScanner=new Scanner(System.in);
10         f[1]=BigInteger.ONE;
11         f[2]=BigInteger.ONE;
12         for(int i=3;i<1010;i++)
13             f[i]=f[i-1].add(f[i-2]);
14         int n;
15         while(cinScanner.hasNext())
16         {
17             n=cinScanner.nextInt();
18             for(int i=0;i<n;i++)
19                 a[i]=cinScanner.nextInt();
20             for(int i=0;i<n;i++)
21                 System.out.println(f[a[i]]);
22         }
23         
24         
25     }
26 
27 }

 

posted on 2012-11-02 19:20  仁者无敌8勇者无惧  阅读(114)  评论(0编辑  收藏  举报

导航