Cod sursa(job #425824)

Utilizator FlorianFlorian Marcu Florian Data 26 martie 2010 10:11:23
Problema Diamant Scor 100
Compilator cpp Status done
Runda Simulare CNITV 2 Marime 0.6 kb
using namespace std;
#include<fstream>
int N, M, X;
const int MAX_S = 90007, C = 44100, mod = 10000,MAX = 44100;
int nr[MAX_S], aux[MAX_S];
int main()
{
	
	ifstream in("diamant.in"); ofstream out("diamant.out");
	in>>N>>M>>X;
	int i,j, s;
	if(X < -MAX || X > MAX) { out<<"0\n"; return 0; }
	nr[C] = 1;
	for(i = 1; i <= N; ++i)
		for(j = 1; j <= M; ++j)
		{
			for(s = 0; s < MAX_S; ++s)
				aux[s] = nr[s];
			for(s = 0; s < MAX_S; ++s)
				if(aux[s])
				{
					nr[s-i*j] += aux[s]; nr[s-i*j]%=mod;					
					nr[s+i*j] += aux[s]; nr[s+i*j]%=mod;
				}
		}
	out<<nr[X+C]<<"\n";
	return 0;
}