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

Added by:Pablo Ariel Heiber
Date:2010-09-27
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

hide comments
2016-06-12 03:25:02 candide
After dozens of tentatives, my Python 3 code got AC in 0.00s (use ceil division). Nice problem. Input has a trailing line.
2016-05-13 23:02:35 Luis Herrera
The comments section should be in another page, people just post their solutions instead of hints.
2016-05-10 16:12:04
@zacle please make sure that you don't post answers in comments.
2016-04-20 15:31:48
Finally ac.....
2016-04-09 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
2016-04-08 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 :|
2016-03-27 11:42:32
can you please give one more test case of unequal numbers of G and B, to understand this problem better.
2016-03-18 19:46:23
Easy!! AC in first go :)
2016-03-13 12:45:09
Am i a slow thinker or everybody took almost 40 minutes to solve this?????Please let me know
2016-03-11 19:21:59 Dinu Bhai
AC in one go...simple direct formula...
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.