Cod sursa(job #2185664)

Utilizator Shield137Ion Parjet Shield137 Data 24 martie 2018 18:59:10
Problema Diamant Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.72 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>2870 || x<-2870){
		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;	
	}
	
	400 + 361 + 324 + 289 + 256 + 225 + 196 + 169