GIRLSNBS - Girls and Boys

no tags 

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
coder271: 2016-11-23 14:36:15

good question::--> my 50th;;

dbag007: 2016-11-11 12:28:39

i loved this problem !

adi_pra: 2016-10-21 19:57:05

thanks @narutohokage_1 for your motivation .

narutohokage_1: 2016-10-02 17:09:49

Please moderator , do not remove my comment . As it is to motivate and i am not disclosing any code or hint .

narutohokage_1: 2016-10-02 17:08:36

@hparmar_cs13 no you are no dumb or slow learner ..... you are just trying and it may take 45 min more or a day , when i decided to do this problem i was lost at beginning , know that your brain is malleable. Growth is not fixed , you can always learn anything . You are no less than other. A genius is 100 percent hard work. Talent are hard work done before nothing else ..by you or your parents. Never give up... a hard work can defeat talent when talent doesn't work hard.

narutohokage_1: 2016-10-02 17:06:16

Never ever listen to comment they just make you feel sick and loose motivation , just know that problem is hard before solving and after solving it seems easy also .... think on you own on this problem even if you take time , just think on your own ....

surajmall: 2016-10-02 12:04:52

be carefull when a=0 and b=0 cause a WA

Rajat Saxena: 2016-08-11 22:20:10

hahaha

baadshah_: 2016-06-22 12:32:59

some Test cases:
100 1 ->50
999 88 ->12
12 22 ->2
666 223 ->3
0 0 ->0

pranjalikumar9: 2016-06-21 22:18:59

ceil(a/b) is wrong..dont forget to use ceil((double)a/b) if using ceil function..costed me a wa..silly thing


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