#include<iostream>
using namespace std;
int lim, ans;
void test(int t, int l, int r)
{
int p, pos;
if (t == lim)
ans++;
else
{
pos = lim & (~(t | l | r));
while (pos)
{
p = pos & (-pos);
pos -= p;
test(t + p, (l | p) << 1, (r | p) >> 1);
}
}
}
int main()
{
int n;
while (cin >> n)
{
ans = 0;
lim = (1 << n) - 1;
test(0, 0, 0);
cout << ans << endl;
}
return main();
}
N皇后位运算版
最新推荐文章于 2024-04-18 17:44:01 发布