Saturday, April 9, 2011

10161 - Ant on a Chessboard


#include<iostream>
#include<cmath>
#include<cstdlib>
using namespace std;
int main()
{
    long x,y,t,p;
    long double s;
    freopen("in.txt","r",stdin);
    while(cin>>t&&t)
    {
        s=sqrt(t);
        x=ceil(s);
        y=x-abs(x*(x-1)-t+1);
        p=s+0.5;
        if((p&1)){t=x,x=y,y=t;}
        cout<<x<<" "<<y<<endl;
    }
    exit(0);
}

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.