GIRLSNBS - Girls and Boys
There are G girl students and B boy students in a class that is about to graduate. You need to arrange them in a single row for the graduation. To give a better impression of diversity, you want to avoid having too many girls or too many boys seating consecutively. You decided to arrange the students in order to minimize the gender regularity. The gender regularity of an arrangement is the maximum number of students of the same gender (all girls or all boys) that appear consecutively. Given G and B, calculate the minimum gender regularity among all possible arrangements.
Each test case is described using a single line. The line contains two integers G and B representing the number of girls and boys in the class, respectively (0 ≤ G, B ≤ 1000). The end of input is indicated with a line containing the number −1 twice.
For each test case, output a single line with a single integer representing the minimum gender regularity that an arrangement of G girls and B boys can have.
Hint: Use gapping method like in pnc
try to construct a formula by taking different cases
Pigeon Hole Principle :D
no need to handle edge-cases if you have a correct formula
take care of case 0 0
case 1 0 or 0 1
simple first divide minimum+1 with max and take ceil
5 line code in python always remember if input is 5 1 total six student so you put 1 in mid that 2 partitions but thats why you have to divide it by min(g,b) +1 that give you right anwer ez pz ac in one go because showoff is good for you mental health
Take minimum of girls and boys and divide total students. The problem is basically how many partitions can be done in x objects with y different objects.