結果
問題 | No.401 数字の渦巻き |
ユーザー |
![]() |
提出日時 | 2016-07-22 23:29:23 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 42 ms / 2,000 ms |
コード長 | 820 bytes |
コンパイル時間 | 163 ms |
コンパイル使用メモリ | 82,204 KB |
実行使用メモリ | 55,008 KB |
最終ジャッジ日時 | 2024-11-06 09:26:44 |
合計ジャッジ時間 | 2,320 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 30 |
ソースコード
n = int(input())ans = [["" for i in range(n)] for j in range(n)]i = 0j = 0imax = nimin = 0jmax = njmin = 1cnt = 0cnt2 = 0while True:# 右while i < imax:cnt += 1ans[j][i] = '{0:03d}'.format(cnt)i += 1if cnt >= n * n:breaki -= 1imax -= 1j += 1# 下while j < jmax:cnt += 1ans[j][i] = '{0:03d}'.format(cnt)j += 1j -= 1jmax -= 1i -= 1# 左while i >= imin:cnt += 1ans[j][i] = '{0:03d}'.format(cnt)i -= 1i += 1imin += 1j -= 1if cnt >= n * n:break# 上while j >= jmin:cnt += 1ans[j][i] = '{0:03d}'.format(cnt)j -= 1j += 1jmin += 1i += 1for i in range(n):print(" ".join(ans[i][:]))