UVA - 10161 Ant on a Chessboard

#include<cstdio>
int main() {
int t ;
while( scanf("%d",&t) , t ) {
int x = 1, y = 1 , squ = 1, la;
if( t == 1 ) { printf("1 1\n"); continue;}
for(int i = 1; i*i <= t ; i++ )
squ = i;
t = t - squ*squ;
if( squ % 2 )
y = squ;
else x = squ;
if( !t ) {  printf("%d %d\n", x , y ); continue; }
if( t <= squ + 1 ) {
if( x == 1) {
y += 1;
x = t;
}
else if( y == 1 ) {
x += 1;
y = t;
}
}
else {
if( y == 1 ) {
y += squ;
x -= t - ( squ + 1 ) - 1 ;
}
else if( x == 1) {
x += squ;
y -= t - ( squ + 1 ) - 1;
}
}
printf("%d %d\n", x , y );
}
return 0;
}

• 本文已收录于以下专栏：

uva 10161 Ant on a Chessboard 蛇形矩阵 简单数学题

• hcbbt
• 2013年07月25日 15:01
• 1403

UVa 10161 - Ant on a Chessboard

Problem A.Ant on a Chessboard    Background   One day, an ant called Alice came to an M*M chessbo...

uva10161 Ant on a Chessboard

Description  Problem A.Ant on a Chessboard    Background   One day, an...

UVA 10161 Ant on a Chessboard

Ant on a Chessboard    Background   One day, an ant called Alice came to an M*M chessbo...

UVA - 10161 - Ant on a Chessboard

http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=99&page=show_problem&p...

Ant on a Chessboard

Problem A.Ant on a Chessboard    Background   One day, an ant called Alice came to an M*M chess...

uva12633 Super Rooks on Chessboard

FFT
• sdfzyhx
• 2017年04月20日 21:22
• 233

举报原因： 您举报文章：UVA - 10161 Ant on a Chessboard 色情 政治 抄袭 广告 招聘 骂人 其他 (最多只允许输入30个字)