Pagini recente » Cod sursa (job #2611030) | Cod sursa (job #2964293) | Cod sursa (job #1581213) | Cod sursa (job #2363339) | Cod sursa (job #2564345)
#include <iostream>
#include <fstream>
#include <cmath>
using namespace std;
const int valmax=44100;
const int modulo=10000;
ifstream f ("diamant.in");
ofstream g ("diamant.out");
int n,m,x,dp[2][2*valmax+10],i,j,k,acm=1,vch=0;
void rest(int &x)
{
if(x>=modulo) x-=modulo;
}
int main()
{
f >> n >> m >> x;
x+=valmax;
if(x>2*valmax) {
g << 0;
return 0;
}
dp[0][valmax]=1;
for(i=1; i<=n; i++)
for(j=1; j<=m; j++) {
for(k=0; k<=2*valmax; k++) {
dp[acm][k]=0;
if(k-i*j>0) {
dp[acm][k]=dp[acm][k]+dp[vch][k-i*j];
rest(dp[acm][k]);
}
if(k+i*j<=2*valmax) {
dp[acm][k]=dp[acm][k]+dp[vch][k+i*j];
rest(dp[acm][k]);
}
dp[acm][k]=dp[acm][k]+dp[vch][k];
rest(dp[acm][k]);
}
swap(acm,vch);
}
g << dp[vch][x];
return 0;
}