4300966 2006-02-01 17:20:17 Accepted 0.002 Minimum 28565 C++ 10161 - Ant on a Chessboard
~cpp
#include <iostream>
#include <math.h>
using namespace std;
void process(int num)
{
int level, temp, x, y;
level = ceil(sqrt(num));
temp = num - (level-1)*(level-1);
if(temp > level)
{
x = level;
y = 2*level - temp;
}
else
{
y = level;
x = temp;
}
if(level % 2 == 0)
cout << x << " " << y << endl;
else
cout << y << " " << x << endl;
}
int main()
{
int num;
cin >> num;
while(num)
{
process(num);
cin >> num;
}
return 0;
}