dfs思路的八皇后
#include<bits/stdc++.h>
using namespace std;
#define lint long long
int l[110]={0},lx[110]={0},rx[110]={0},lj[110]={0};
int n,ans=0;
void dfs(int h){
if(h==n+1) {
/*
if(ans<3){
for(int i=1;i<=n;i++) cout << lj[i] << ' ';
cout << endl;
}*/ //输出前三个解
ans++;
return ;
}
for(int i=1;i<=n;i++){
if(rx[h-i]==0 && lx[h+i]==0 && l[i]==0){
rx[h-i]=1; lx[h+i]=1; l[i]=1; lj[h]=i;
dfs(h+1);
rx[h-i]=0; lx[h+i]=0; l[i]=0; lj[h]=0;
}
}
return ;
}
int main(){
cin >> n;
dfs(1);
cout << ans;
return 0;
}