From 97abf9d71eb72cd3d4f718e3bc2a75b5440b4768 Mon Sep 17 00:00:00 2001 From: ShreyaswadE Date: Thu, 28 May 2020 18:12:12 +0530 Subject: [PATCH 1/2] a number change --- .../Explanations/Candies Explanation.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Contests/Educational DP Contest/Explanations/Candies Explanation.txt b/Contests/Educational DP Contest/Explanations/Candies Explanation.txt index c670e2e..f9be986 100644 --- a/Contests/Educational DP Contest/Explanations/Candies Explanation.txt +++ b/Contests/Educational DP Contest/Explanations/Candies Explanation.txt @@ -1,6 +1,6 @@ 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. So, f(i, j) = f(i - 1, j ) + f(i - 1, j - 1) + ... + f(i - 1, j - A[i] - 1) @@ -54,4 +54,4 @@ int main() cout << no_of_ways[no_of_people][no_of_candies]; return 0; -} \ No newline at end of file +} From b19a67b7dd57d7fda5bcdc41ef4ff0c03b2609dd Mon Sep 17 00:00:00 2001 From: ShreyaswadE Date: Thu, 28 May 2020 18:17:09 +0530 Subject: [PATCH 2/2] Update Candies Explanation.txt --- .../Educational DP Contest/Explanations/Candies Explanation.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Contests/Educational DP Contest/Explanations/Candies Explanation.txt b/Contests/Educational DP Contest/Explanations/Candies Explanation.txt index f9be986..372f0d1 100644 --- a/Contests/Educational DP Contest/Explanations/Candies Explanation.txt +++ b/Contests/Educational DP Contest/Explanations/Candies Explanation.txt @@ -4,7 +4,7 @@ Then we can give the i-th person - 0, 1, 2, ... , A[i] chocolates. 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). So the base case is that f(0, 0) = 1 and f(0, j) = 0 for all other j.