Cod sursa(job #162822)

Utilizator gcosminGheorghe Cosmin gcosmin Data 20 martie 2008 19:20:59
Problema Diamant Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.6 kb
#include <stdio.h>
#include <string.h>

#define MOD 10000
#define off 50000

int N, M, K;

int ant[100010];
int cur[100010];

int main()
{
	int i, j, q, w, k;

	freopen("diamant.in", "r", stdin);
	freopen("diamant.out", "w", stdout);

	scanf("%d %d %d", &N, &M, &K);

	if (K > off || -K > off) {  printf("0\n"); return 0; }

	ant[off] = 1;

	q = 0;
	for (i = 1; i <= N; i++)
		for (j = 1; j <= M; j++) {
			q += i * j; w = i * j;

			for (k = off - q; k <= off + q; k++)
				cur[k] = (ant[k - w] + ant[k + w] + ant[k]) % 10000;

			memcpy(ant, cur, sizeof(ant));
		}

	printf("%d\n", cur[off + K]);

return 0;
}