uva 10161 - Ant on a Chessboard #include<cstdio>
#include<cmath>
#include<algorithm>
#define LL long long
int main()
{
LL N;
while((scanf("%lld",&N),N)!=0)
{
LL t = sqrt(N);//計算ant在第幾層//每層都已平方數開頭或結束
if(t*t < N ) t++;
LL m = ((t-1)*(t-1)+1+t*t)/2;//計算這層中間的數是多少
if(N == m)printf("%lld %lld\n",t,t);
else if(t % 2== 1)//奇數層
{
if(N > m)printf("%lld %lld\n",t-(N-m),t);
else
printf("%lld %lld\n",t,t-(m-N));
}
else
if(t % 2 == 0)//偶數層
{
if(N > m)printf("%lld %lld\n",t,t-(N-m));
else printf("%lld %lld\n",t-(m-N),t);
}
}
return 0;
}