dp to get the result of the combinations_with_replacement