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.
Input
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.
Output
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.
Example
Input:
10 10
5 1
0 1000
1 1
Output:
1
3
1000
hide comments
candide:
20160612 03:25:02
After dozens of tentatives, my Python 3 code got AC in 0.00s (use ceil division). Nice problem. Input has a trailing line. 

Luis Herrera:
20160513 23:02:35
The comments section should be in another page, people just post their solutions instead of hints. 

ianand:
20160510 16:12:04
@zacle please make sure that you don't post answers in comments. 

pamyjeela:
20160420 15:31:48
Finally ac..... 

zacle:
20160409 18:16:00
AC in one go...if girls>boys the output is (girsls / (boys+1) ) or ((girls/(boys+1))+1) do the same if boys>girls by replacing boys by girls and don't forget to check the case where both are 0 or the same number..if they are 0 print 0 else 1..Hope that can help 

mickey_v:
20160408 08:18:41
for 5 1 the solution that i thought was g g g g b g but the solution is g g g b g g. hope that helps other.25th atlast : 

deependrasingh:
20160327 11:42:32
can you please give one more test case of unequal numbers of G and B, to understand this problem better.


shubham9466:
20160318 19:46:23
Easy!! AC in first go :)


hparmar_cs13:
20160313 12:45:09
Am i a slow thinker or everybody took almost 40 minutes to solve this?????Please let me know 

Dinu Bhai:
20160311 19:21:59
AC in one go...simple direct formula...

Added by:  Pablo Ariel Heiber 
Date:  20100927 
Time limit:  2s 
Source limit:  50000B 
Memory limit:  1536MB 
Cluster:  Cube (Intel G860) 
Languages:  All except: ASM64 NODEJS OBJC VB.NET 
Resource:  FCEyN UBA ICPC Selection 2010 