What is wrong with my logic fr problem ICL1903?

I am not able to get my mind through this very easy problem.

These are my submissions:
https://www.codechef.com/viewsolution/23693234
https://www.codechef.com/viewsolution/23686250

This is an accepted submission:
https://www.codechef.com/viewsolution/23688005

I also tried reading the problem statement many times to understand what I was doing wrong.

I’d be very grateful if someone can point out why my logic is incorrect.

1 Like

Suppose there are 20 candies , 6 friends and value of k = 4 . Now , according to you 20%6 = 2 and since 2%4 is not = 0 , therefore , you say there is no possible distribution and output answer as -1 . But the correct answer is 2 . Suppose you throw k = 4 candies twice . So , now the candies remaining are = 12 , and this can be distributed equally among the 6 friends .

3 Likes

Thanks a lot @garyhost I understand my mistake now :slight_smile:
I’ll work on my skills to develop test cases so that I don’t make the same mistake again.

2 Likes