Cod sursa(job #425933)

Utilizator tudalexTudorica Constantin Alexandru tudalex Data 26 martie 2010 11:50:41
Problema Diamant Scor 100
Compilator cpp Status done
Runda Simulare CNITV 2 Marime 0.58 kb
#include <stdio.h>
#include <string.h>
const int base = 10000;
int a[100000],
    b[100000];
int n, m, i, j, t, x;
int main()
{
	freopen("diamant.in","r",stdin);
	freopen("diamant.out","w",stdout);
	scanf("%d %d %d", &n, &m, &x);
	a[50000] = 1;
	if (x > 45000 || x < -45000)
	{
		printf("0\n");
		return 0;
	}
	for (i = 1; i<= n; ++ i)
		for (j = 1; j <= m; ++ j)
		{
			int p = i*j;
			memcpy(b,a,sizeof(a));
			
			for (t = 1000; t <= 99000; ++ t)
			{
				a[t]  = b[t] + b[t-p] + b[t+p];
				while (a[t] >= base)
					a[t] -=base;
			}
		}
	printf("%d", a[50000+x]%base);
	return 0;
}