提交时间:2023-10-05 17:52:35
运行 ID: 105235
#include<bits/stdc++.h> using namespace std; int n,b,cnt; int a[14],vsist[14]; int zhu[30],fu[30]; void dfs(int x) { if(x==n+1){ cnt++; return; } for(int i = 1;i <= n;i++){ if(vsist[i] == 0&&zhu[x-i+n] == 0&&fu[x+i] == 0){ a[x] = i; vsist[i] = zhu[x-i+n] = fu[x+i] = 1; dfs(x+1); vsist[i] = vsist[i] = zhu[x-i+n] = fu[x+i] = 0; } } } int main() { scanf("%d%d",&n,&b); dfs(1); printf("%d",cnt); return 0; }