Pagini recente » Monitorul de evaluare | Cod sursa (job #687729) | Cod sursa (job #2720894) | Cod sursa (job #3179212) | Cod sursa (job #3135817)
#include <iostream>
#include <vector>
#include <map>
#include <cstring>
#include <fstream>
#include <sstream>
#include <string>
#include <algorithm>
#include <queue>
#include <cmath>
#include <set>
#include <unordered_map>
#include <stack>
#include <iomanip>
#include <random>
#include <climits>
using namespace std;
ifstream fin("diamant.in");
ofstream fout("diamant.out");
const int MAX = 1e5 + 1;
const int MOD = 1e4;
int numberOfCombination[MAX];
int main() {
int n, m;
long long x;
fin >> n >> m >> x;
if (x < 0) {
x *= -1;
}
vector<int> square;
int maxSum = 0;
for (int i = 0; i < n; ++i) {
for (int j = 0; j < m; ++j) {
square.push_back((i + 1) * (j + 1));
maxSum += (i + 1) * (j + 1);
}
}
if (x > maxSum) {
fout << "0";
return 0;
}
if (x == maxSum) {
fout << "1";
return 0;
}
numberOfCombination[0] = 1;
for (int i = 0; i < (int) square.size(); ++i) {
for (int j = maxSum; j >= square[i] ; --j) {
numberOfCombination[j] += numberOfCombination[j - square[i]];
if (j >= 2 * square[i]) {
numberOfCombination[j] += numberOfCombination[j - 2 * square[i]];
}
numberOfCombination[j] = numberOfCombination[j] % MOD;
}
}
fout << numberOfCombination[maxSum - x];
return 0;
}