Skip to content

Conversation

ShreyaswadE
Copy link
Contributor

No description provided.

Let f(i, j) be the number of ways of distributing j chocolates to the first i people.

Then we can give the j-th person - 0, 1, 2, ... , A[i] chocolates.
Then we can give the i-th person - 0, 1, 2, ... , A[i] chocolates.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The i-th person can get a[i] candies. not the j-th

So, f(i, j) = f(i - 1, j ) + f(i - 1, j - 1) + ... + f(i - 1, j - A[i] - 1)

If (j - A[i] - 1), then f(i, j) = f(i - 1, j) + ... + f(i - 1, 0).
If (j = A[i] - 1), then f(i, j) = f(i - 1, j) + ... + f(i - 1, 0).
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

simply putting in the above formula

@MathProgrammer MathProgrammer merged commit ef99d2a into MathProgrammer:master Jun 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants