#include <stdio.h>
#include <math.h>
int main()
{
long x;
while(1){
scanf("%ld",&x);
if(x==0)
break;
int sqr=ceil(sqrt(x));
long i,j;
if(sqr%2==0){
long temp=sqr*sqr-sqr+1;
i=sqr;
j=sqr;
while(temp<x){
j--;
temp++;
}
while(temp>x){
i--;
temp--;
}
}
else{
long temp=sqr*sqr-sqr+1;
i=sqr;
j=sqr;
while(temp<x){
i--;
temp++;
}
while(temp>x){
j--;
temp--;
}
}
printf("%ld %ld\n",i,j);
}
return 0;
}
#include <math.h>
int main()
{
long x;
while(1){
scanf("%ld",&x);
if(x==0)
break;
int sqr=ceil(sqrt(x));
long i,j;
if(sqr%2==0){
long temp=sqr*sqr-sqr+1;
i=sqr;
j=sqr;
while(temp<x){
j--;
temp++;
}
while(temp>x){
i--;
temp--;
}
}
else{
long temp=sqr*sqr-sqr+1;
i=sqr;
j=sqr;
while(temp<x){
i--;
temp++;
}
while(temp>x){
j--;
temp--;
}
}
printf("%ld %ld\n",i,j);
}
return 0;
}
No comments:
Post a Comment