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; }
相关文章推荐
- UVA - 10161 Ant on a Chessboard
- UVA 10161 - Ant on a Chessboard(数学)
- Uva10161 Ant on a Chessboard
- UVa 10161 - Ant on a Chessboard
- UVa-10161-Ant on a Chessboard
- 10161 - Ant on a Chessboard
- UVA 10161 Ant on a Chessboard
- uva 10161 Ant on a Chessboard 蛇形矩阵 简单数学题
- UVA - 10161 - Ant on a Chessboard
- UVA 10161 (暑假-数学-B - Ant on a Chessboard)
- UVa-10161-Ant on a Chessboard
- UVa:10161 - Ant on a Chessboard
- UVa 10161 Problem A.Ant on a Chessboard
- UVA10161 Ant on a Chessboard
- uva 10161 - Ant on a Chessboard
- uva 10161 Ant on a Chessboard
- UVa10161 Ant on a Chessboard
- uva 10161 - Ant on a Chessboard
- uva 10161 Ant on a Chessboard
- uva 10161 - Ant on a Chessboard