Pagini recente » Cod sursa (job #1398752) | Cod sursa (job #2932130) | Cod sursa (job #75726) | Cod sursa (job #3205175) | Cod sursa (job #2502887)
#include <fstream>
#include <vector>
using namespace std;
ifstream fin("diamant.in");
ofstream fout("diamant.out");
const int MAX_S = 44500;
int N, M, X;
vector <int> el;
int dp[2 * MAX_S + 5][2];
int main()
{
fin >> N >> M >> X;
int smax = 0;
for(int i = 1; i <= N; i++)
for(int j = 1; j <= M; j++)
{
el.push_back(i * j);
smax += i * j;
}
if(X < -smax || smax < X)
{
fout << 0 << '\n';
return 0;
}
int currentCol = 0;
dp[0 + MAX_S][0] = 1;
for(int step = 0; step < N * M; step++)
{
currentCol = !currentCol;
for(int value = -smax + MAX_S; value <= smax + MAX_S; value++)
{
dp[value][currentCol] = dp[value - el[step]][!currentCol];
dp[value][currentCol] += dp[value][!currentCol];
dp[value][currentCol] += dp[value + el[step]][!currentCol];
dp[value][currentCol] %= 10000;
}
}
fout << dp[X + MAX_S][currentCol] << '\n';
return 0;
}