标签:
1 8 5 0
1 92 10
1 #include <bits/stdc++.h> 2 using namespace std; 3 int uplimit,ret,n; 4 void dfs(int row,int ld,int rd){ 5 if(row == uplimit) ++ret; 6 else{ 7 int pos = uplimit & (~(row|ld|rd)); 8 while(pos){ 9 int p = pos&(-pos); 10 pos ^= p; 11 dfs(row|p,(ld|p)<<1,(rd|p)>>1); 12 } 13 } 14 } 15 int main(){ 16 while(scanf("%d",&n),n){ 17 uplimit = (1<<n)-1; 18 ret = 0; 19 dfs(0,0,0); 20 printf("%d\n",ret); 21 } 22 return 0; 23 }
标签:
原文地址:http://www.cnblogs.com/crackpotisback/p/4591974.html