Created
August 13, 2014 08:58
-
-
Save sota1235/cb037df8c96ab4216551 to your computer and use it in GitHub Desktop.
AOJ #0078
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # AOJ | |
| # http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0078 | |
| while True: | |
| n = input() | |
| if n == 0: break | |
| board = [[0] * n for i in range(n)] | |
| xp = n / 2 | |
| yp = n / 2 + 1 | |
| for i in range(n ** 2): | |
| if board[yp][xp] == 0: | |
| board[yp][xp] = i + 1 | |
| else: | |
| xp -= 1 | |
| yp += 1 | |
| if xp == -1: xp = n - 1 | |
| if yp == n : yp = 0 | |
| board[yp][xp] = i + 1 | |
| yp += 1 | |
| xp += 1 | |
| if xp == n: xp = 0 | |
| if yp == n: yp = 0 | |
| for b in board: | |
| print "".join(map(lambda x:str("% 4d" % x), b)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment