diff --git "a/2109020144/chap3/\345\256\236\351\252\2148.cpp" "b/2109020144/chap3/\345\256\236\351\252\2148.cpp" new file mode 100644 index 0000000000000000000000000000000000000000..0310a4fe4cc66651997871de9fc85b835e4521a6 --- /dev/null +++ "b/2109020144/chap3/\345\256\236\351\252\2148.cpp" @@ -0,0 +1,38 @@ +#include +using namespace std; +typedef long long ll; +int n; +int a[100]; +int b[100]; +int c[100]; +int d[100]; +int total; +void getin() { + cin >> n; +} +void dfs(int i) { + if (i > n) { + total++; + return; + } + for (int j = 1; j <= n; j++) { + if (b[j] == 0 && c[i + j] == 0 && d[i - j + n] == 0) { + a[i] = j; + b[j] = 1; + c[i + j] = 1; + d[i - j + n] = 1; + dfs(i + 1); + b[j] = 0; + c[i + j] = 0; + d[i - j + n] = 0; + } + } +} +int main() { + std::ios::sync_with_stdio(false); + std::cin.tie(nullptr); + getin(); + dfs(1); + cout << total; + return 0; +} \ No newline at end of file