#include<iostream>
#include<cstring>
#include<stdlib.h>
#include<algorithm>
#include<cmath>
using namespace std;
int n,k,ans;
char m[9][9];
bool c[9];
//int dx[4]={0,-1,0,1};
//int dy[4]={-1,0,1,0};
void dfs(int depth,int exist)
{
if(exist==k)
{
ans++;
return ;
}
if(depth==n)
return ;
for(int i=0;i<n;i++)
{
if(m[depth][i]=='#'&&c[i]==false)
{
c[i]=true;
dfs(depth+1,exist+1);
c[i]=false;
}
}
dfs(depth+1,exist);
}
int main()
{
while(cin>>n>>k&&(n!=-1)&&(k!=-1))
{
for(int i=0;i<n;i++)
cin>>m[i];
ans=0;
memset(c,false,sizeof(c));
dfs(0,0);
cout<<ans<<endl;
}
return 0;
}
poj1321
最新推荐文章于 2019-08-10 09:48:44 发布