#include #include #include #include #include #include #include using namespace std; int main() { /* Enter your code here. Read input from STDIN. Print output to STDOUT */ int N; cin >> N; for (int i = 1; i < N; ++i) { for (int j = 1; j < N; ++j) { vector> dist(N, vector(N,-1)); queue> Q; Q.push(make_pair(0,0)); dist[0][0] = 0; while(!Q.empty()) { auto cur = Q.front(); Q.pop(); auto cur_dist = dist[cur.first][cur.second]; for (int x = -i; x <= i; x += 2*i) { for (int y = -j; y <= j; y += 2*j) { int new_x = cur.first+x; int new_y = cur.second+y; if (new_x >= 0 && new_x < N && new_y >= 0 && new_y < N && dist[new_x][new_y] < 0) { Q.push(make_pair(new_x, new_y)); dist[new_x][new_y] = cur_dist + 1; } swap(new_x, new_y); if (new_x >= 0 && new_x < N && new_y >= 0 && new_y < N && dist[new_x][new_y] < 0) { Q.push(make_pair(new_x, new_y)); dist[new_x][new_y] = cur_dist + 1; } } } } cout << dist[N-1][N-1] << ((j==N-1)? "" : " "); } if (i != N-1) cout << endl; } return 0; }