Cod sursa(job #35041)

Utilizator MariusMarius Stroe Marius Data 21 martie 2007 19:18:55
Problema Diamant Scor 10
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.77 kb
#include <cstdio>
#include <memory>
using namespace std;

const char iname[] = "diamant.in";
const char oname[] = "diamant.out";

#define lim    44505
#define inf  - 44101
#define sup    44101
#define modulo 10000
#define MAX_V  1 << 17

int A[MAX_V];
#define A (A + lim)

int B[MAX_V];
#define B (B + lim)


int main(void)
{
	freopen(iname, "r", stdin);
	int N;
	int M;
	int X;
	scanf("%d %d %d", & N, & M, & X);

	freopen(oname, "w", stdout);
	if (X > sup) {
		printf("0\n");
		return 0;
	}
	A[0] = 1;
	for (int i = 1; i <= N; ++i) {
		for (int j = 1; j <= M; ++j) 
		{
			for (int k = inf; k < sup; ++k) 
				B[k] = (A[k - (i * j)] + A[k] + A[k + (i * j)]) % modulo;
			memcpy(A, B, sizeof(B));
		}
	}
	printf("%d\n", A[X]);
	return 0;
}