hdu2177

#include 
#include 
#include 

using namespace std;

#define oo (~0U >> 1)
#define MAXN 1000 + 10

int temp[MAXN];
int node[MAXN];
int as[1000 * MAXN][2];

void input()
{
    int a, b;

    for (int i = 0; i < 1000000 + 10; i++)
    {
        as[i][0] = (int)(2 * i / (sqrt((double)5) - 1));
        as[i][1] = as[i][0] + i;
    }

    while (cin >> a >> b, a + b)
    {
        if (a > b)
        {
            int t = a;
            a = b;
            b = t;
        }

        int k = (b - a);

        if (a == (int)(2 * k / (sqrt((double)5) - 1)))
        {
            cout << 0 << endl;
        }
        else
        {
            cout << 1 << endl;

            if (a == b)
            {
                cout << "0 0" << endl;
            }
            else
            {
                int ak = (int)(2 * k / (sqrt((double)5) - 1)), bk = ak + k;

                if (a >= ak && b >= bk && (a - ak) == (b - bk))
                {
                    cout << ak << ' ' << bk << endl;
                }

                for (int i = 0; i <= a; i++)
                {
                    if (a == as[i][0])
                    {
                        cout << as[i][0] << ' ' << as[i][1] << endl;
                        break;
                    }
                    else if (a == as[i][1])
                    {
                        cout << as[i][0] << ' ' << as[i][1] << endl;
                        break;
                    }
                }
            }
        }
    }
}

int main()
{
    input();
    return 0;
}

你可能感兴趣的:(ACM->简单博弈)