Poj Solution 3112

http://poj.org/problem?id=3112

#include <stdio.h>


int m[1000];

int main( ) {
    int n, p, c, i, j, t, ans;

    while( 1 ) {
        scanf( "%d%d%d", &p, &n, &c );
        if( n == 0 && p == 0 && c == 0 )
            break;

        for( j=0; j<p; j++ )
            m[j] = 0;
        
        ans = 0;

        for( i=0; i<n; i++ ) {
            for( j=0; j<p; j++ ) {
                scanf( "%d", &t );
                if( t == 0 ) {
                    if( m[j] >= c )ans++;
                    m[j] = 0;
                }
                else
                    m[j]++;
            }
        }
        for( j=0; j<p; j++ )
            if( m[j] >= c )
                ans++;
        printf( "%dn", ans );
    }
    return 0;
}
											
This entry was posted in poj. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *