Cod sursa(job #420863)

Utilizator otilia_sOtilia Stretcu otilia_s Data 20 martie 2010 17:58:51
Problema Diamant Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.71 kb
#include <cstdio>
using namespace std;
#define MOD 10000
#define NMAX 44100
#define NTOT 88240
int C[NTOT],C2[NTOT];

int main()
{
	freopen("diamant.in","r",stdin);
	freopen("diamant.out","w",stdout);
	int n,m,X,i,j,h,stot,smax;
	
	scanf("%d %d %d",&n,&m,&X);
	smax=(n*(n+1)/2)*(m*(m+1)/2);
	if (X>smax || X<-smax) { printf("0\n"); return 0;}
	stot=smax*2+2;
	
	C2[smax]=1; //0
	for (i=1;i<=n;++i)
	 for (j=1;j<=m;++j)
	  {
		for (h=0;h<=stot;++h) C[h]=C2[h];
		int p=i*j;
		
		for (h=0;h<=stot;++h)
		 if (C[h]) 
		    {
				C2[h+p]+=C[h];
				if (C2[h+p]>MOD) C2[h+p]-=MOD;
				C2[h-p]+=C[h];
				if (C2[h-p]>MOD) C2[h-p]-=MOD;
		    }
	  }	
	 
	printf("%d",C2[X+smax]);
	
	return 0;
}