#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;
const int maxn=
100;
int vis[
3][maxn];
int n;
int tot=
0;
void search(
int cur)
{
if(cur==n) tot++
;
else
for(
int i=
0;i<n;i++
)
if(!vis[
0][i] && !vis[
1][cur+i] && !vis[
2][cur-i+
n])
{
vis[0][i]=vis[
1][cur+i]=vis[
2][cur-i+n]=
1;
search(cur+
1);
vis[0][i]=vis[
1][cur+i]=vis[
2][cur-i+n]=
0;
}
}
int main()
{
memset(vis,0,
sizeof(vis));
cin>>
n;
search(0);
printf("%d\n",tot);
return 0;
}
看了看以前的shceme版也好有趣
转载于:https://www.cnblogs.com/tclan126/p/7428021.html
转载请注明原文地址: https://win8.8miu.com/read-1542883.html