Pagini recente » Cod sursa (job #2072699) | Cod sursa (job #641098) | Cod sursa (job #511296) | Cod sursa (job #1430805) | Cod sursa (job #2789814)
#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);
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];
if(j >= -nrmax + a[i])
dp[line][j + nrmax] += dp[1 - line][j - a[i] + nrmax];
if(j + a[i] <= nrmax)
dp[line][j + nrmax] += dp[1 - line][j + a[i] + nrmax];
}
fout << dp[1 - line][X + nrmax] << "\n";
return 0;
}