POJ 3181 Dollar Dayz

最近各种无力,脑残了都……此题大数,无槽点……

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

public class Main{

	static Scanner cin = new Scanner(System.in);
	static PrintWriter cout = new PrintWriter(System.out, true);

	public static void main(String[] args) {
		int n, k;
		BigInteger dp[] = new BigInteger[1002];
		while (cin.hasNext()) {
			n = cin.nextInt();
			k = cin.nextInt();
			dp[0] = BigInteger.ONE;
			for (int i = 1; n >= i; i++)
				dp[i] = BigInteger.ZERO;
			for (int i = 1; k >= i; i++) {
				for (int j = i; n >= j; j++) {
					dp[j] = dp[j].add(dp[j - i]);
				}
			}
			cout.println(dp[n]);
		}
	}
}

你可能感兴趣的:(POJ 3181 Dollar Dayz)