Solve of UVA 12908: The book thief
#include<bits/stdc++.h>
using namespace std;
int main()
{
long int n,i,j,k,l,x;
while(scanf("%ld",&x)==1)
{
if(x==0) return 0;
n=(-1+sqrt(1+8*x))/2;
if((n*(n+1))/2==x)
printf("%ld %ld\n",n+1,n+1);
else
printf("%ld %ld\n",((n+1)*(n+2))/2-x,n+1);
}
return 0;
}
No comments:
Post a Comment