【大数问题】 HDOJ 1715 大菲波数

又一个大数题。。。

import java.util.Scanner;
import java.math.BigInteger;
import java.math.BigDecimal;

public class Main
{
	public static void main(String[] args)
	{
		Scanner scanner = new Scanner(System.in);
		BigInteger f[] = new BigInteger[1005];
		f[1] = BigInteger.valueOf(1);
		f[2] = BigInteger.valueOf(1);
		for(int i = 3; i <= 1000; i++) {
			f[i] = BigInteger.ZERO;
			f[i] = f[i].add(f[i-1]);
			f[i] = f[i].add(f[i-2]);
		}
		while(scanner.hasNext()) {
			int t = scanner.nextInt();
			for(int i = 1;  i<= t; i++) {
				int n = scanner.nextInt();
				System.out.println(f[n]);
			}
		}
	}
}


你可能感兴趣的:(HDU)