10161

Ant on a Chessboard
Type: Math  
Diff: 3.0

Tricks

Here we can think that the ant is in a box of ceil(sqrt(n)) X ceil(sqrt(n)) cross board. Then we can calculate the outer shell of that cross board where the ant is now. Then find out the position of the top right corner of the board. If ceil(sqrt(n)) is even then the position starts from lower right and else from upper left. So we can easily calculate the position.

One important trick is, when you calculate the upper right of the board, careful about the  tempose1. You need to use double or larger then unsigned integer range.

Careful about the variable conversion.

Related Problems & Topics

264 Count on Cantor

If you have any advice, complements 

or proposal, please  Send mail to Author

Submit

 

1