Problem Link: http://www.spoj.com/problems/CANDY/

So here in this problem the teacher has to evenly distribute the candies to avoid fights among the children. So first we have to have find can we distribute evenly. For that we need to check whether totalcandies%bag packs==0 or not?

If we can divide evenly then calculate the number of moves by moving candies from the bag pack which has more than average number of candies.

Solution Link: https://github.com/bharaththiruveedula/Algorithms/blob/master/SPOJ/CANDY.java

Advertisements