Pagini recente » Cod sursa (job #410893) | Cod sursa (job #2409020) | Cod sursa (job #836230) | Cod sursa (job #2916047) | Cod sursa (job #2789795)
#include <bits/stdc++.h>
using namespace std;
ifstream fin("diamant.in");
ofstream fout("diamant.out");
int n, m, dp[2][90000], 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];
dp[line][j + nrmax] += dp[1 - line][j - a[i] + nrmax];
dp[line][j + nrmax] += dp[1 - line][j + a[i] + nrmax];
}
fout << dp[1 - line][X + nrmax] << "\n";
return 0;
}