Pagini recente » Cod sursa (job #1018251) | Cod sursa (job #2902998) | Cod sursa (job #2233783) | Cod sursa (job #824556) | Cod sursa (job #1688284)
#include <iostream>
#include <fstream>
#include <cmath>
using namespace std;
int n, m, x;
int main() {
ifstream input("diamant.in");
input >> n >> m >> x;
int ossz = n*(n + 1) / 2 * m*(m + 1) / 2;
int pozitiv[ossz*2 + 1];
int alt[ossz*2 + 1];
for (int i = 0; i <= (ossz*2 + 1); i++) {
pozitiv[i] = 0;
alt[i] = 0;
}
pozitiv[0] = 1;
int end = 1;
for (int y = 1; y <= n; y++) {
for (int x = 1; x <= m; x++) {
int ertek = x*y;
end += ertek;
for (int i = 0; i <= end; i++) {
alt[i] = pozitiv[i];
}
for (int i = 0; i <= end; i++) {
int a = abs(i - ertek);
alt[i] = (pozitiv[i] + pozitiv[i + ertek] + pozitiv[a])%10000;
}
for (int i = 0; i <= end; i++) {
pozitiv[i] = alt[i];
}
}
}
int a = abs(x);
ofstream output ("diamant.out");
output << pozitiv[a]%10000 << '\n';
output.close();
return 0;
}