K - 棋盘问题
src="https://vjudge.net/problem/description/8028?1516216029000" width="100%" height="950px" frameborder="0" scrolling="no" style="box-sizing: inherit;">
#include<stdio.h>
#include<string.h>
char map[11][11];
int k, n, sum, cur, book[8];
void dfs(int hang)
{
int i, j;
if(cur==k)
sum++;
else
{
if(hang>=n)
return ;
else
{
for(i=0;i<n;i++)
if(!book[i] && map[hang][i]=='#')
{
cur++;
book[i]=1;
dfs(hang+1);
cur--;
book[i]=0;
}
dfs(hang+1);
}
}
}
int main()
{
int i;
while(~scanf("%d%d", &n, &k))
{
if(n==-1 && k==-1)
break;
sum=0;cur=0;
memset(book, 0, sizeof(book));
for(i=0;i<n;i++)
scanf("%s", map[i]);
dfs(0);
printf("%d\n", sum);
}
return 0;
}