~cpp #include <iostream> #include <cmath> using namespace std; int step, i, j, temp, counting; #define x_loc 1 #define y_loc 0 int calculate(int st, int xy) { i=xy; while(true) { counting=1; if(st==1) return 1; if(st>pow(i,2) && st<=pow(i+2,2)) { temp = st-pow(i,2); for(j=1; j<i+1; j++) { temp--; if(temp==0) return counting; counting++; } for(j=1; j<i+2; j++) { temp--; if(temp==0) return counting; } counting++; for(j=1; j<i+3; j++) { temp--; if(temp==0) return counting; } counting--; for(j=1; j<i+2; j++) { temp--; if(temp==0) return counting; counting--; } } i=i+2; } } int main() { while(cin>>step) { if(step==0) break; cout << calculate(step, x_loc) << " " << calculate(step, y_loc) << endl; } return 0; }