Problem solving with programming: Boys and Girls - SPOJ problem
Given some number of boys and girls, we have to arrange them in a row such that the same gender appear together is minimized.
We have to find the minimum number of any gender appear together in any arrangement.
We have to divide the bigger number by smaller number plus 1.
Consider that there are N boys and M girls (N > M). The optimal way of arranging them is to put one girl between a group of (N/M+1) boys.
Read full article from Problem solving with programming: Boys and Girls - SPOJ problemwhile (true){int g,b;cin >> g >> b;if( g == -1 && b == -1 )break;else{int r;if( g > b )r = ceil( (double)g/(b+1) );elser = ceil( (double)b/(g+1) );cout << r << endl;}}