Pagini recente » Cod sursa (job #1286657) | Cod sursa (job #2600675) | Cod sursa (job #889620) | Cod sursa (job #1575402) | Cod sursa (job #2937079)
#include <bits/stdc++.h>
#define MOD 10000
using namespace std;
ifstream fin("diamant.in");
ofstream fout("diamant.out");
int n, m, x, len;
int dp[2][95000], a[405];
int main()
{
fin >> n >> m >> x;
if (abs(x) > n*(n+1)/2*m*(m+1)/2)
fout<<0<<"\n";
else
{
for (int i=1; i<=n; i++)
{
for (int j=1; j<=m; j++)
{
a[++len] = i*j;
}
}
x += 45000;
dp[0][45000] = 1;
int L = 0;
for (int i = 1; i <= len; i++)
{
L = 1 - L;
for (int j = 0; j <= 90000; j++)
{
dp[L][j] = dp[1-L][j];
if (j >= a[i])
{
dp[L][j] += dp[1-L][j-a[i]];
}
dp[L][j] += dp[1-L][j+a[i]];
dp[L][j] = dp[L][j] % MOD;
}
}
fout << dp[L][x];
}
return 0;
}