Chef and Candies

Please explain me the formula/logic of the chef and candies in simple !!!

Bro read the last line of explanation of sample test case. You will get to know yourself.
Hint: You can take any integer part of n to satisfy our condition(k number of chocolates ),
Let’s take an example, (n,m,k)=(3,1,10),
–>if you don’t read the last line of explanation, your code will produce , answer as 9(As you will take n as a whole in last iteration as well)
–>If you read it, figured out, you will get to know, just have make minor changes in the code, to get 8 as a answer. In last iteration, when your total_candy_count_till_now = 8(n is 6) , just had to add 2 more to get a 10(total_candy_count_now==k)

2 Likes