FZU 2064 找位置

来源:互联网 发布:网络播放器哪个最好 编辑:程序博客网 时间:2024/06/08 20:54

Problem Description

一年一次的FZUACM宣讲会又开始 了,kk和几个同学到的时候位置已经不多了。但是他们又想坐在同一排而且位置要连在一起。现在给你宣讲会现场的情况请问有多少种座法满足条件,对于两种坐法如果有一个位置不同就算是两种不同的坐法。

Input

第一行一个整数T,表示有T组数据。

每组数据第一行三个正整数N M W(1<N,M,W<=100), 表示宣讲会现场是一个N*M 的座位和kk一伙来了W个人。其中N是排数,M是列数。

接着N行每行M个数(0或1),0表示空位,1表示有人坐了。

Output

对于每组数据,输出有多少种坐法。

Sample Input

22 3 30 0 11 0 02 5 30 1 0 1 00 0 0 0 0

Sample Output

03
#include <iostream>#include <cstdio>#include <cstring>#include <algorithm>using namespace std;const int MAXN = 105;int map[MAXN][MAXN];int n,m,w;int main(){    int t;    scanf("%d",&t);    while (t--){        scanf("%d%d%d",&n,&m,&w);        memset(map,0,sizeof(map));        for (int i = 1; i <= n; i++)            for (int j = 1; j <= m; j++)                scanf("%d",&map[i][j]);        int ans = 0;        for (int i = 1; i <= n; i++)            for (int j = 1; j <= m; j++){                int k = j;                while (1){                    if (map[i][k]|| k > m)                        break;                    ++k;                }                if (k >= j+w)                    ans++;            }        printf("%d\n",ans);    }    return 0;}


原创粉丝点击