#include #include #include using namespace std; const int N = 100; int res = 0; int h[N]; bool st[N]; void dfs(int cnt,int cur,int n){ if (cnt == n){ res ++; return ; } //向左走 //int temp1=(cur + cnt) % n; // int temp1; if (cur + cnt > n){ temp1 = (cur + cnt) % n; }else temp1 = cur + cnt; if (!st[temp1]){ st[temp1] = true; dfs(cnt + 1,temp1,n); st[temp1] = false; } //向右走 //int temp2=(cur-cnt+n)%n; int temp2; if (cur-cnt < 1){ temp2 = n - (cnt - cur); }else { temp2 = cur - cnt; } if (!st[temp2]){ st[temp2] = true; dfs(cnt + 1,temp2,n); st[temp2] = false; } } int main(){ int T; scanf("%d",&T); while (T--){ int n; scanf("%d",&n); if(!h[n]) { res = 0; memset(st,0,4*(n+1)); st[1] = true; dfs(1,1,n); h[n]=res; } printf("%d\n",h[n]); } return 0; }