You have several identical balls that you wish to place in several baskets. Each basket has the same maximum capacity. You are given an int baskets, the number of baskets you have. You are given an int capacity, the maximum capacity of each basket. Finally you are given an int balls, the number of balls to sort into baskets. Return the number of ways you can divide the balls into baskets. If this cannot be done without exceeding the capacity of the baskets, return 0.
Each basket is distinct, but all balls are identical. Thus, if you have two balls to place into two baskets, you could have (0, 2), (1, 1), or (2, 0), so there would be three ways to do this.
int, int, int
int countWays(int baskets, int capacity, int balls)
(be sure your method is public)
baskets will be between 1 and 5, inclusive.
capacity will be between 1 and 20, inclusive.
balls will be between 1 and 100, inclusive.
The example from the problem statement.
We have only 1 ball, so we must choose which of the three baskets to place it in.
We can place both balls in the same basket (3 ways to do this), or one ball in each of two baskets (3 ways to do this).
We have more balls than our basket can hold.
This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2003, TopCoder, Inc. All rights reserved.