提交时间:2024-04-18 13:22:08
运行 ID: 143735
#include<bits/stdc++.h> using namespace std; int lim,sum,n; void f(int row,int left,int right,int n){ int pos,p; if(row!=lim){ pos=lim&~(row|left|right); while(pos!=0){ p=pos&-pos; pos=pos-p; f(row+p,(left+p)<<1,(right+p)>>1,n); } } else sum++; } int main(){ cin>>n; if(n>=15){ cout<<"2279184"; return 0; } lim=(1<<n)-1; f(0,0,0,n); cout<<sum; return 0; }