알고리즘/codefights

3>candies

Diademata 2018. 5. 19. 23:16
반응형

n children have got m pieces of candy. They want to eat as much candy as they can, but each child must eat exactly the same amount of candy as any other child. Determine how many pieces of candy will be eaten by all the children together. Individual pieces of candy cannot be split.


Example


For n = 3 and m = 10, the output should be

candies(n, m) = 9.


Each child will eat 3 pieces. So the answer is 9. 


code>>


int candies(int n, int m) {

return m / n * n;

}

반응형

'알고리즘 > codefights' 카테고리의 다른 글

5>maxMultiple  (0) 2018.05.19
4>seatsInTheater  (0) 2018.05.19
2>largestNumber  (0) 2018.05.19
1>addTwoDigits  (0) 2018.05.19
60>sudoku  (0) 2018.04.14