Stars And Bars

Stars And Bars

Hard Computer Mathematics Combinatorics 28 views
Explanation Complexity

Problem Statement

Count solutions of x1+...+xk = n with xi>=0.

Input Format

Two integers n k.

Output Format

One integer.

Example

4 3
15

Constraints

n

Input / Output Format

Input Format
Two integers n k.
Output Format
One integer.
Constraints
n

Examples

Input:
4 3
Output:
15

Example Solution (Public)

Computer Mathematics
Number is C(n+k-1,k-1). Compute with nCr method.

Official Solution Code

Number is C(n+k-1,k-1). Compute with nCr method.
Please login to submit solutions.
Editor
Output

                                        
Please login to submit solutions.