Cod sursa(job #2185671)

Utilizator Shield137Ion Parjet Shield137 Data 24 martie 2018 19:02:50
Problema Diamant Scor 50
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.67 kb
#include<bits/stdc++.h>
using namespace std;


ifstream in("diamant.in");
ofstream out("diamant.out");

int nw[100000],old[100000];
using namespace std;
int main()
{
	long long x;
	int n,m,i,j,k;
	//freopen("input.txt","r",stdin);
	in>>n>>m>>x;
	if(x>44100 || x<-44100){
		cout<<0;
		return 0;
	}
	old[4999]=old[5000]=old[5001]=1;
	for(i=1;i<=n;i++)
		for(j=1;j<=m;j++)
			if( !( (i==1)&&(j==1) ) ){
				for(k=500;k<9500;k++)
					nw[k]=((old[k]+old[k-i*j])%10000+old[k+i*j])%10000;
	/*
				for(k=5000-10;k<5000+10;k++)
					cout<<nw[k]<<" ";
				cout<<endl;
	*/
				for(k=500;k<9500;k++)
					old[k]=nw[k];
				}
	out<<old[x+5000];
	return 0;	
	}