Skip to content

Commit ef99d2a

Browse files
Merge pull request #2 from ShreyaswadE/patch-1
a number change
2 parents 696600d + b19a67b commit ef99d2a

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

Contests/Educational DP Contest/Explanations/Candies Explanation.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
Let f(i, j) be the number of ways of distributing j chocolates to the first i people.
22

3-
Then we can give the j-th person - 0, 1, 2, ... , A[i] chocolates.
3+
Then we can give the i-th person - 0, 1, 2, ... , A[i] chocolates.
44

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

7-
If (j - A[i] - 1), then f(i, j) = f(i - 1, j) + ... + f(i - 1, 0).
7+
If (j = A[i] - 1), then f(i, j) = f(i - 1, j) + ... + f(i - 1, 0).
88

99
So the base case is that f(0, 0) = 1 and f(0, j) = 0 for all other j.
1010

@@ -54,4 +54,4 @@ int main()
5454

5555
cout << no_of_ways[no_of_people][no_of_candies];
5656
return 0;
57-
}
57+
}

0 commit comments

Comments
 (0)