Search This Blog

Sunday, 21 August 2016

SPOJ - Girls And Boys Problem Solution

SPOJ - Girls And Boys Problem Solution

Solution:-

#include<bits/stdc++.h>
using namespace std;

int main()
{
    int g,b;
    while(1)
    {
        cin>>g>>b;
        if(g==-1 && b==-1)
            break;
        else if(g==0 && b==0)
            cout<<g;
        else if(g>b)
            cout<<ceil(double(g)/(b+1));
        else
            cout<<ceil(double(b)/(g+1));

    cout<<endl;
    }

}

No comments:

Post a Comment