HDU1250HDU1250
求第i个斐波那契数问题:

总结:
数组尽量往大开,不要超内存。
不是很难。

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

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		BigInteger f[] = new BigInteger[10000];//数组开到一万....
		f[1] = f[2] = f[3] = f[4] = BigInteger.ONE;

		for (int i = 5; i < f.length; i++)
			f[i] = f[i - 1].add(f[i - 2]).add(f[i - 3]).add(f[i - 4]);

		while (in.hasNext()) {
			int n = in.nextInt();
			System.out.println(f[n]);
		}
	}
}