void caHelp(int &res,vector &v,int N,int cnt){ if(cnt==N+1) { ++res; return; } for(int i=1;i<=N;++i) { if(v[i]==0&&(i%cnt==0||cnt%i==0)) { v[i]=1; caHelp(res,v,N,cnt+1); v[i]=0; } }}int countArrangement(int N){ int res=0; vector v(N+1,0); caHelp(res,v,N,1); return res;}