結果
問題 |
No.401 数字の渦巻き
|
ユーザー |
|
提出日時 | 2018-08-28 00:20:20 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 31 ms / 2,000 ms |
コード長 | 836 bytes |
コンパイル時間 | 122 ms |
コンパイル使用メモリ | 12,800 KB |
実行使用メモリ | 11,008 KB |
最終ジャッジ日時 | 2024-07-05 21:18:24 |
合計ジャッジ時間 | 1,898 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 30 |
ソースコード
N = int(input()) l = [[0] * N for i in range(N)] d = 0 x = 0 y = 0 for i in range(1, N**2 + 1): if d % 4 == 0: l[x][y] = str(i).zfill(3) y += 1 if y >= N or l[x][y] != 0: d += 1 y -= 1 x += 1 elif d % 4 == 1: l[x][y] = str(i).zfill(3) x += 1 if x >= N or l[x][y] != 0: d += 1 x -= 1 y -= 1 elif d % 4 == 2: l[x][y] = str(i).zfill(3) y -= 1 if y < 0 or l[x][y] != 0: d += 1 y += 1 x -= 1 elif d % 4 == 3: l[x][y] = str(i).zfill(3) x -= 1 if l[x][y] != 0: d += 1 x += 1 y += 1 ans = "" for i in l: ans = "" for j in i: ans += j ans += " " print(ans)