标签:ret namespace poj1321 char main poj while pre amp
1 #include<iostream> 2 #include<cstdio> 3 #include<algorithm> 4 #include<cstring> 5 #include<string> 6 using namespace std; 7 int n,k,sum; 8 char map[10][10]; 9 int vis[10]; 10 int dfs(int x,int y) 11 { 12 int i; 13 if(!y) 14 { 15 sum++; 16 return 0; 17 } 18 if(x<0)return 0; 19 for(i=0;i<n;i++) 20 { 21 if(map[x][i]==‘#‘&&vis[i]==0) 22 { 23 vis[i]=1; 24 dfs(x-1,y-1); 25 vis[i]=0; 26 } 27 } 28 dfs(x-1,y); 29 } 30 int main() 31 { 32 int i,j,c,d; 33 while(cin>>n>>k&&n!=-1&&k!=-1) 34 { 35 sum=0; 36 memset(vis,0,sizeof(vis)); 37 for(i=0;i<n;i++) 38 cin>>map[i]; 39 dfs(n,k); 40 cout<<sum<<endl; 41 } 42 }
标签:ret namespace poj1321 char main poj while pre amp
原文地址:http://www.cnblogs.com/--lr/p/6959307.html