Author, developer, author of the solution: Andriy Stolitniy
Each girl must end up with the same number of apples. Let this number be x. Then
Then, if a girl has more than x apples, she must give away the excess. The answer to the problem will be