Pagini recente » Cod sursa (job #2182146) | Cod sursa (job #1831874) | Cod sursa (job #2913487) | Cod sursa (job #1072852) | Cod sursa (job #2229976)
#include <cstdio>
#include <cstring>
using namespace std;
const int mod = 10000;
int sol[2][320005];
int ind[2][2];
int main()
{ freopen("diamant.in", "r",stdin);
freopen("diamant.out", "w",stdout);
int n,m,x,k,i,j,kk;
scanf("%d%d%d", &n, &m, &x);
ind[0][0]=ind[0][1]=160000;
ind[1][0]=-1000000;
ind[1][1]=1000000;
sol[0][160000]++;
k=0;
for(i=1; i<=n; i++){
for(j=1; j<=m; j++){
for(kk=ind[k%2][1]; kk>=ind[k%2][0]; kk--)
if(sol[k%2][kk]){
sol[(k+1)%2][kk+i*j]+=sol[k%2][kk];
sol[(k+1)%2][kk+i*j]%=mod;
sol[(k+1)%2][kk-i*j]+=sol[k%2][kk];
sol[(k+1)%2][kk-i*j]%=mod;
sol[(k+1)%2][kk]=sol[k%2][kk];
}
ind[(k+1)%2][0]=ind[k%2][0]-i*j;
ind[(k+1)%2][1]=ind[k%2][1]+i*j;
memset(sol[k%2], 0, sizeof(sol[k%2]));
k++;
}
}
if(x>=-160000 && x<=160000){
x+=160000;
printf("%d", sol[k%2][x]);
}
else
printf("0");
return 0;
}