#P4370. Maximizing the Sum of Distinct Binomial Coefficients

    ID: 17616 Type: Default 1000ms 256MiB

Maximizing the Sum of Distinct Binomial Coefficients

Maximizing the Sum of Distinct Binomial Coefficients

You are given two integers n and k. Consider all binomial coefficients \(\binom{a}{b}\) with 0 \leq b \leq a \leq n. Two binomial coefficients \(\binom{a_1}{b_1}\) and \(\binom{a_2}{b_2}\) are considered distinct if \(a_1 \neq a_2\) or \(b_1 \neq b_2\). Your task is to choose k distinct binomial coefficients from these such that their sum is maximized, and output this maximum sum.

Note: The binomial coefficient \(\binom{a}{b}\) is defined for \(0 \leq b \leq a\) where \(\binom{a}{b}=\frac{a!}{b!(a-b)!}\). All inputs given in this problem are such that n will be small enough (for example, \(n \leq 50\)) to allow exact computation using 64-bit integers.

inputFormat

The first line contains two integers n and k separated by a space.

outputFormat

Output a single integer representing the maximum sum of the chosen k distinct binomial coefficients.

sample

2 2
3