#33601: _ans


yp11151230@yphs.tp.edu.tw (909-42蔡亞儒)


#include <bits/stdc++.h>
using namespace std;

int n, counter;

void dfs(unsigned col, unsigned diag1, unsigned diag2) {
    if (col == n) counter++;
    for (unsigned ava=n&~(col|diag1|diag2), now=ava&-ava; // now is the current position to be placed.
        ava; ava^=now, now=ava&-ava) // ava is short for available columns.
        dfs(col|now, (diag1|now)<<1, (diag2|now)>>1);
}

int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); // IO 優化
    while (cin >> n)
        counter=0, n=(1<<n)-1, dfs(0, 0, 0), cout << counter << '\n';
    return 0;
}