水題就自己 trace ㄅ (很懶的寫解題流程)

 

#include <iostream>
#include <cmath>

using namespace std;

int main()
{
    int second;
    while(cin >> second && second){
        int round = sqrt(second);

        second -= round*round;
        if(!second){
            if(round % 2)
                cout << "1 " << round << endl;
            else
                cout << round << " 1" << endl;

            continue;
        }
        else
            round += 1;

        int x, y = 0;
        if(round%2)
            second > round ? (x = 2*round - second, y = round) : (x = round, y = second);
        else
            second > round ? (x = round, y = 2*round - second) : (x = second, y = round);

        cout << x << " " << y << endl;
    }

    return 0;
}

arrow
arrow
    全站熱搜

    大神(偽) 發表在 痞客邦 留言(0) 人氣()