水題就自己 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;
}
留言列表