5 1 2 3 4 5
1 1 2 3 5
import java.util.Scanner; import java.math.BigInteger; public class yhrtr { public static void main(String[] args) { Scanner cin = new Scanner (System.in); BigInteger s[] = new BigInteger[1005]; s[1] = BigInteger.ONE; s[2] = BigInteger.ONE; for(int i=3;i<=1000;i++) s[i] = s[i-1].add(s[i-2]); int n = cin.nextInt(); for(int i=0;i<n;i++) { int m = cin.nextInt(); System.out.println(s[m]); } } }
原文地址:http://blog.csdn.net/hyccfy/article/details/38231131