Pagini recente » Cod sursa (job #109233) | Cod sursa (job #1470081) | Cod sursa (job #2304101) | Cod sursa (job #964901) | Cod sursa (job #1571308)
#include <fstream>
#include <cmath>
using namespace std;
ifstream fin("diamant.in");
ofstream fout("diamant.out");
const int NMAX = 88300;
const int MOD = 10000;
int N, M, X, SMax, dist;
int PD[2][NMAX];
int main()
{
fin >> N >> M >> X;
SMax = ((N * (N + 1)) / 2) * ((M * (M + 1)) / 2);
if(abs(X) > SMax) { fout << "0\n"; return 0; }
PD[0][SMax] = 1;
for(int i = 1; i <= N; i++)
for(int j = 1; j <= M; j++)
{
dist += i * j;
for(int k = -dist + SMax; k <= dist + SMax; ++k)
PD[1][k] = (PD[0][k] + PD[0][k - i * j] + PD[0][k + i * j]) % MOD;
for(int k = -dist + SMax; k <= dist + SMax; ++k)
PD[0][k] = PD[1][k], PD[1][k] = 0;
}
fout << PD[0][X + SMax] << '\n';
return 0;
}