Problem

Source: Vietnam TST 2023 P1

Tags: combinatorics



A school has two classes $A$ and $B$ which have $m$ and $n$ students each. The students of the two classes sit in a circle. Each student is then given a number of candies equal to the number of consecutive students sitting to the left of him that are from his same class. After distributing the candies, the teacher decides to group the students such that in each group, all the students receive the same amount of candies, and any two students from two different groups should receive a different amount of candies. a) What is the maximum number of students that a group can have? b) Excluding the group where every student receives no candies, what is the maximum number of students that a group can have?