题目地址:点击打开链接.
C++代码:
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
int a;
while(true)
{
cin>>a;
if(a==0)
break;
int n=sqrt(a);
if(n%2==1)
{
a=a-n*n;
if(a==0)
cout<<1<<" "<<n<<endl;
else
{ if(a<=n+1)
cout<<a<<" "<<n+1<<endl;
else
cout<<n+1<<" "<<2*n+2-a<<endl;
}
}
else
{
a=a-n*n;
if(a==0)
cout<<n<<" "<<1<<endl;
else
{
if(a<=n+1)
cout<<n+1<<" "<<a<<endl;
else
cout<<2*n+2-a<<" "<<n+1<<endl;
}
}
}
return 0;
}