Pagini recente » Cod sursa (job #2592995) | Cod sursa (job #1765258) | Cod sursa (job #1694234) | Cod sursa (job #169708) | Cod sursa (job #2458855)
#include <bits/stdc++.h>
#define MAX 131072
using namespace std;
const int NMAX = 45000;
const int MOD = 10000;
FILE *IN, *OUT;
int N, M, X, sMax;
int dp[2][2 * NMAX];
int pos, sign;
char f[MAX];
inline int modulo(int x){
if(x >= MOD)
x -= MOD;
return x;
}
inline void Read(int &nr){
sign = 0;
nr = 0;
while(f[pos] < '0' || f[pos] > '9'){
if(f[pos] == '-') sign = 1;
pos++;
if(pos == MAX)
fread(f, MAX, 1, IN), pos = 0;
}
while(f[pos] >= '0' && f[pos] <= '9'){
nr = 10 * nr + f[pos++] - '0';
if(pos == MAX)
fread(f, MAX, 1, IN), pos = 0;
}
if(sign) nr =- nr;
}
int main(){
IN = fopen("diamant.in", "r");
freopen("diamant.out", "w", stdout);
Read(N); Read(M); Read(X);
for(int i = 1; i <= N; i++)
for(int j = 1; j <= M; j++) sMax += i * j;
X = abs(X);
if(sMax < X){
printf("0");
return 0;
}
dp[0][0] = 1;
int line = 1;
for(int i = 1; i <= N; i++){
for(int j = 1; j <= M; j++){
int cnt = i * j;
for(int k = 0; k <= sMax; k++)
dp[line][k] = modulo(dp[1 - line][abs(cnt - k)] + dp[1 - line][k] + dp[1 - line][cnt + k]);
line = 1 - line;
}
}
printf("%d", dp[1 - line][X]);
return 0;
}