#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;
}
uva 10161 - Ant on a Chessboard
最新推荐文章于 2019-02-19 11:45:02 发布