题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1715
题目大意:打印第p个斐波那契数。
题目分析:略
代码参考:
import java.util.*;
import java.math.*;
public class Main{
public static void main(String args[]){
@SuppressWarnings("resource")
Scanner in = new Scanner(System.in);
int i, t, n;
BigInteger f[] = new BigInteger[1009];
f[1] = new BigInteger("1");
f[2] = new BigInteger("1");
for(i=3; i<=1000; ++i){
f[i] = f[i-1].add(f[i-2]);
}
t = in.nextInt();
while(t--!=0){//不能写成while(t--)
n = in.nextInt();
System.out.println(f[n]);
}
}
}