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
naman_mawandia: 2019-08-04 07:29:29

case 1 0 or 0 1
output is 1

aryan29: 2019-06-03 18:10:10

Easiest

shaakal: 2019-05-22 12:29:37

simple first divide minimum+1 with max and take ceil

aj_254: 2019-05-06 06:49:30

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

klmo: 2019-04-26 19:00:59

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.

sarthak_1998: 2019-03-30 13:44:21

What am I doing wrong here, I have tested the code with every single test case given in the comments and passed them all but still getting WA.
https://www.spoj.com/submit/GIRLSNBS/id=23528225

un_st0ppable: 2019-03-12 21:07:30

AC in one go!!

maddy_nov: 2019-03-09 06:14:32

Last edit: 2019-03-09 06:15:10
shubham97361: 2019-03-01 18:39:02

use double if you are using ceil().

zakir068: 2019-02-28 09:57:24

10/3 = 3+3+4


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