#include using namespace std; bool visited[26][26] ; vector< pair > knightL(int a, int b, int x, int y, int n){ vector > new_; pair mov[8]; mov[0] = make_pair( x + a, y + b); mov[1] = make_pair( x + a, y - b); mov[4] = make_pair( x - a, y + b); mov[5] = make_pair( x - a, y - b); mov[2] = make_pair( x + b, y + a); mov[3] = make_pair( x + b, y - a); mov[6] = make_pair( x - b, y + a); mov[7] = make_pair( x - b, y - a); //cout << "HERE"; for(int i = 0; i < 8; i++){ int x_ = mov[i].first, y_ = mov[i].second; if(!visited[x_][y_] && !(x_ > n - 1 || y_ > n - 1 || x_ < 0 || y_ < 0) ) { visited[x_][y_] = true; new_.push_back(mov[i]); //cout << mov[i].first << ' ' << mov[i].second << '\n'; } } return new_; } int knightL_aux(int a, int b, int n){ if(a > b){ int t = a; a = b; b = t; } vector< pair > cur; cur.push_back(make_pair(0,0)); visited[0][0] = true; int i = 0; while(find(cur.begin(), cur.end(), make_pair(n - 1, n - 1)) == cur.end() && cur.size() != 0){ i++; vector< pair >::iterator it; vector< pair > new_; for(it = cur.begin(); it != cur.end(); it++){ vector< pair > new_i = knightL(a,b,(*it).first, (*it).second, n); new_.insert(new_.end(), new_i.begin(), new_i.end()); } swap(new_, cur); } if(find(cur.begin(), cur.end(), make_pair(n - 1, n - 1)) != cur.end()){ return i; }else{ return -1; } } void init(){ for(int k = 0; k < 25; k++){ for(int l = 0; l < 25; l++){ visited[k][l] = false; } } } int main(){ int n; cin >> n; for(int i = 1; i