0

Can anyone help me solve this problem

You are dividing up building block toys by color into even amounts for all of the kids in a 15 person kindergarten class. You don't want to give anyone more than anyone else, so you might have some leftover blocks of each color in the end. How many total do you have left over? Task: If you know how many of each color block you have, add up the leftover blocks to come up with the amount you will have after you have evenly distributed each color to all 15 students. Input Format: 4 integers that represent the blue, red, green, and yellow blocks that you are sorting out (in that order). Output Format: An integer of the total remaining blocks after you have distributed an even amount to all 15 students. Sample Input: 150 20 300 53 Sample Output: 13

20th Nov 2022, 4:30 AM
Ming
Ming - avatar
2 Answers
+ 3
You can solve it by modulo operator. Compute the modulo n % 15 for each block n and sum them all up.
20th Nov 2022, 6:54 AM
Oma Falk
Oma Falk - avatar
+ 1
Oma Falk Thank you !!
20th Nov 2022, 9:25 AM
Ming
Ming - avatar