Pagini recente » Cod sursa (job #3134189) | Cod sursa (job #1254059) | Cod sursa (job #2326959) | Cod sursa (job #1179016) | Cod sursa (job #2789799)
#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 <= X;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;
}