Poj Solution 3036

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

#include <stdio.h>


int ans[20][40][40] = { 0 };

int main( ) {
    int i, j, k, t;
    ans[0][20][20] = 1;
    for( i=0; i<14; i++ ) {
        for( j=1; j<39; j++ )
            for( k=1; k<39; k++ ) {
                t = ans[i][j][k];
                ans[i+1][j][k-1] += t;
                ans[i+1][j][k+1] += t;
                ans[i+1][j-1][k] += t;
                ans[i+1][j-1][k-(j%2?1:-1)] += t;
                ans[i+1][j+1][k] += t;
                ans[i+1][j+1][k-(j%2?1:-1)] += t;
            }
    }
    scanf( "%d", &t );
    while( t-- ) {
        scanf( "%d", &k );
        printf( "%dn", ans[k][20][20] );
    }
    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 *