Pagini recente » Cod sursa (job #3228539) | Cod sursa (job #2118727) | Cod sursa (job #81693) | Cod sursa (job #1118830) | Cod sursa (job #2178679)
#include <bits/stdc++.h>
using namespace std;
unordered_map<int,int> DP[2];
ifstream fin("diamant.in");
ofstream fout("diamant.out");
int N,M,X;
const int lim = 50000;
int main(){
cin >> N >> M >> X;
bool u = 1;
DP[!u][0] = 1;
if (abs(X) > lim) {
fout << 0;
return 0;
}
for (int i = 1; i <= N;i++){
for (int j = 1; j <= M;j++,u = !u){
for (int k = lim; k >= -lim;k--) DP[u][k] = DP[!u][k - i*j] + DP[!u][k] + DP[!u][k + i*j], DP[u][k] = DP[u][k] % 10000;
// for (int k = lim; k >= -lim;k--) cout <<k<< "-"<< DP[!u][k] << " ";
// cout << endl;
// for (int k = lim; k >= -lim;k--) cout <<k<< "-"<< DP[u][k] << " ";
// cout << endl;
// cout << endl;
}
}
fout << DP[!u][X] % 10000;
//cout << DP[u][X];
return 0;
}