I am not able to get the correct ans in the code
MY CODE->https://ide.codingblocks.com/s/395892
Distribute chocolates
Bhaiya i was first finding maximum number of chocaltes one children can get and then the remaining chocaltes .I think my code is all incorrect .Cna u please provide me a different approch or solution for the question
Hello @kaustub please see this explanation and the code also :
Initially we are assuming that we are distributing chocolates to students as : 1 , 2 , 3 , … , n ; if it is greater than c there is no point in distributing.
Now, we will subtract n*(n+1)/2 from c; res will be remaining chocolates now we will divide it with n to check if we can give additional chocolates to each of student.
The number which comes after division will be the no. of additional chocolates that can be distributed to each of candidates and remainder will be the answer that is minimum chocolate left.
Here for your reference i am attaching the code:
if you have any further doubt you can ask here:
Happy Learning!!
What does n*(n+1)/2 here denote?
Here we are checking if we will be able to allocate this data or not.
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.