Pagini recente » Cod sursa (job #1683761) | Cod sursa (job #3227597) | Cod sursa (job #321575) | Borderou de evaluare (job #753669) | Cod sursa (job #2789817)
#include <bits/stdc++.h>
using namespace std;
ifstream fin("diamant.in");
ofstream fout("diamant.out");
int n, m, dp[2][100000], X, N;
int a[405];
int main()
{
int i, j;
fin >> n >> m >> X;
for(i = 1;i <= n;i++)
for(j = 1;j <= m;j++)
a[++N] = i * j;
int nrmax = (n * (n + 1) / 2) * (m * (m + 1) / 2);
if(X > nrmax)
fout << "0\n";
int line = 0;
dp[line][nrmax] = 1;
for(line = 1,i = 1;i <= N;i++, line = 1 - line)
for(j = -nrmax;j <= nrmax;j++)
{
dp[line][j + nrmax] = dp[1 - line][j + nrmax] % 10000;
if(j >= -nrmax + a[i])
dp[line][j + nrmax] += dp[1 - line][j - a[i] + nrmax] % 10000;
if(j + a[i] <= nrmax)
dp[line][j + nrmax] += dp[1 - line][j + a[i] + nrmax] % 10000;
}
fout << dp[1 - line][X + nrmax] % 10000 << "\n";
return 0;
}