您的位置:首页 > 其它

10161 - Ant on a Chessboard

2012-09-09 10:35 316 查看
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
int i,j,n;
while(cin>>n)
{
if(n==0) break;
i=pow((double)n,0.5);
j=n-i*i;
if(i%2==0)
{
if(j==0)cout<<i<<" 1"<<endl;
else if(j<=i+1&&j>=1)cout<<i+1<<" "<<j<<endl;
else cout<<2*i+2-j<<" "<<i+1<<endl;
}
else
{
if(j==0)cout<<"1 "<<i<<endl;
else if(j>=1&&j<=i+1)cout<<j<<" "<<i+1<<endl;
else cout<<i+1<<" "<<2*i+2-j<<endl;
}
}
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  ant include