/*
先把平方根為整數的找出來
再去算剩下的
Run time: 0.000
*/
#include <stdio.h>
#include <math.h>
int main()
{
int N;
int k;
int row, col;
while (scanf("%d", &N))
{
if (!N) break;
k = (int)sqrt(N);
if (k*k == N)
{
if (k%2)
printf("1 %d\n", k);
else
printf("%d 1\n", k);
}
else
{
if (k%2)
{
if (N <= k*k+k+1)
printf("%d %d\n", N-k*k, k+1);
else
{
row = col = k+1;
while (N-- != k*k+k+1)
col--;
printf("%d %d\n", row, col);
}
}
else
{
if (N <= k*k+k+1)
printf("%d %d\n", k+1, N-k*k);
else
{
row = col = k+1;
while (N-- != k*k+k+1)
row--;
printf("%d %d\n", row, col);
}
}
}
}
return 0;
}
沒有留言:
張貼留言