#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; int n; int arr[8][2]; bool isValid(int x, int y, int n) { if(x < 0 || y < 0 || x >= n || y >= n){ return false; } return true; } int bfs(pair p1, pair p2) { queue, int> > Que; map, bool> Vis; Que.push(make_pair(p1, 0)); while(!Que.empty()) { pair, int> temp = Que.front(); Que.pop(); if(temp.first.first == p2.first && temp.first.second == p2.second) return temp.second; int x = temp.first.first; int y = temp.first.second; int dis = temp.second + 1; if(Vis.count(make_pair(x, y))) continue; Vis[make_pair(x, y)] = true; for(int i = 0; i < 8; ++i) { int x1 = x + arr[i][0]; int y1 = y + arr[i][1]; if(isValid(x1, y1, n)) Que.push(make_pair(make_pair(x1, y1), dis)); } } return -1; } int main(){ cin >> n; int a, b, x0 = 0, y0 = 0; pair p1; p1.first = 0; p1.second = 0; pair p2; p2.first = n - 1; p2.second = n - 1; for(int i = 1; i < n; ++i) { a = i; for(int j = 1; j < n; ++j) { b = j; arr[0][0] = x0 + a; arr[0][1] = y0 + b; arr[1][0] = x0 - a; arr[1][1] = y0 - b; arr[2][0] = x0 + a; arr[2][1] = y0 - b; arr[3][0] = x0 - a; arr[3][1] = y0 + b; arr[4][0] = x0 + b; arr[4][1] = y0 + a; arr[5][0] = x0 - b; arr[5][1] = y0 - a; arr[6][0] = x0 + b; arr[6][1] = y0 - a; arr[7][0] = x0 - b; arr[7][1] = y0 + a; cout << bfs(p1, p2) << " "; } cout << endl; } return 0; }