#include<stdio.h> #include<stdlib.h> int p[20],a[50],b[50],c[50],ans,n; void dfs(intx){ inti,j,k; if(x==n+1){ ans++; return; } for(i=1;i<=n;i++) if(a[i]+b[x+i]+c[x-i+20]==0){ p[x]=i; a[i]=1; b[x+i]=1; c[x-i+20]=1; dfs(x+1); a[i]=0; b[x+i]=0; c[x-i+20]=0; } } int main(){ int i,j,k,m; scanf("%d",&n); dfs(1); printf("%d ",ans); return0; }