結果
問題 | No.401 数字の渦巻き |
ユーザー |
![]() |
提出日時 | 2016-07-22 22:38:06 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 2,000 ms |
コード長 | 1,670 bytes |
コンパイル時間 | 966 ms |
コンパイル使用メモリ | 111,572 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-11-06 09:05:42 |
合計ジャッジ時間 | 1,911 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 30 |
ソースコード
#include <cstdlib>#include <cmath>#include <climits>#include <cfloat>#include <map>#include <utility>#include <set>#include <iostream>#include <memory>#include <string>#include <vector>#include <algorithm>#include <functional>#include <sstream>#include <deque>#include <complex>#include <stack>#include <queue>#include <cstdio>#include <cctype>#include <cstring>#include <ctime>#include <iterator>#include <bitset>#include <numeric>#include <list>#include <iomanip>#include <cassert>#include <array>#include <tuple>#include <initializer_list>#include <unordered_set>#include <unordered_map>#include <forward_list>using namespace std;using ll = long long;#define rep(i,k) for (int i = 0; i < (int)(k); i++)#define all(c) begin(c), end(c)int main() {int n;while (cin >> n) {int g[50][50];int x = 0;int ci = 0, cj = 0;int w = n - 1;while (w >= 1) {for (int i = 0; i < w; ++i) {g[ci][cj] = ++x;++cj;}for (int i = 0; i < w; ++i) {g[ci][cj] = ++x;++ci;}for (int i = 0; i < w; ++i) {g[ci][cj] = ++x;--cj;}for (int i = 0; i < w; ++i) {g[ci][cj] = ++x;if (i != w - 1) --ci;}w -= 2;++cj;}if (n & 1) g[n / 2][n / 2] = n*n;for (int i = 0; i < n; i++) {for (int j = 0; j < n; j++) {printf("%03d%c", g[i][j], j == n - 1 ? '\n' : ' ');}}}}