当前位置: 代码迷 >> 综合 >> HDU-2553 N皇后问题
  详细解决方案

HDU-2553 N皇后问题

热度:72   发布时间:2023-11-22 01:40:17.0

HDU-2553 N皇后问题

//打表
/*#include<iostream> #include<cstring> using namespace std;const int N = 40;int dx[N],dy[N],dz[N]; int n,ans; int cnt[N];void dfs(int r) {if(r>n){ans++;return;}else{for(int i=1;i<=n;i++){if(!dx[i+r]&&!dy[i]&&!dz[n+r-i]){dx[i+r] = 1;dy[i] = 1;dz[n+r-i] = 1;dfs(r+1);dx[i+r] = 0;dy[i] = 0;dz[n+r-i] = 0;}}}} int main(){for(int i=1;i<=10;i++){ans = 0;n++;memset(dx,0,sizeof(dx));memset(dy,0,sizeof(dy));memset(dz,0,sizeof(dz));dfs(1);cout<<ans<<",";}}*/#include<iostream>using namespace std;int a[]={
    0,1,0,0,2,10,4,40,92,352,724};int main()
{
    int n;while(cin>>n){
    if(n==0) return 0;cout<<a[n]<<endl;}
}