I have no idea where to start in this problem The question is: N number of elements are given. And you must make them all equal by adding 5,2 or 1 while excluding one of the numbers . You must give minimum number of additions.
example input would be:
2 2 3 2 7
and the output being 2
explanation would be that
2 2 3 2 7
you choose 3 and add by 1 making it
3 3 3 3 8
then choose 8 and add by 5:
8 8 8 8 8
I have no idea how to calculate the possible moves or how to make them equal on pen and paper through sheer brute force as it takes too much time. Could any of you please help how I should be solving this problem cause I don't know where to start. Especially in the math department. If you all could help me figure out the theorem or just the general algorithm I should be using I think I should be able to figure out the ode itself
Aucun commentaire:
Enregistrer un commentaire