#K84917. Integer Partition with At Most Y Parts

    ID: 36526 Type: Default 1000ms 256MiB

Integer Partition with At Most Y Parts

Integer Partition with At Most Y Parts

Given two positive integers (X) and (Y), determine the number of ways to partition (X) into at most (Y) positive integers. A partition of an integer is a way of writing it as a sum of positive integers where the order of addends does not matter. The problem can be solved using dynamic programming.

In particular, let (dp[i][j]) denote the number of ways to partition (i) using up to (j) parts. The following recurrence holds for (i \ge j):
(dp[i][j] = dp[i][j-1] + dp[i-j][j]).

Your task is to compute (dp[X][Y]) for the given (X) and (Y).

inputFormat

The input consists of a single line with two space-separated integers (X) and (Y), representing the integer to partition and the maximum number of parts allowed, respectively.

outputFormat

Output a single integer which is the number of ways to partition (X) into at most (Y) positive integers.## sample

4 2
3