Pagini recente » Cod sursa (job #2360084) | Cod sursa (job #495848) | Cod sursa (job #1018856) | Cod sursa (job #391164) | Cod sursa (job #1163463)
/**
daca avem diamantul full de aur inseamna:
1 * ( 1 + 2 + 3 + 4 + ... + 20)
2 * ( 1 + 2 + 3 + 4 + ... + 20)
...
20* ( 1 + 2 + 3 + 4 + ... + 20)
-------------------------------
= (1 + 2 + 3 + 4 + ... + 20)^2 = (20*21)^2/2 =
= 21 *20 * 21 * 20 / 4 = 21^2*10*10 = 441*100 = 44100 suma maxima/minima
*/
#include <cstdio>
#define Nmax 25
#define Smax 3*sup_limit + 5
#define sup_limit 44100
#define down_limit -sup_limit
#define MOD 10000
int DP[2][Smax]; /// DP[dim][s] = nr de comfiguratii de arie dim si cu suma s
int N,M,K;
using namespace std;
int abso(int x){
if(x < 0) return -x;
return x;
}
int main()
{
freopen("diamant.in","r",stdin);
freopen("diamant.out","w",stdout);
scanf("%d%d%d",&N,&M,&K);
int lc = 1,la = 0;
DP[0][sup_limit] = 1;
for(int i = 1; i <= N; ++i)
for(int j = 1; j <= M; ++j)
{
for(int s = 0; s <= 2*sup_limit; ++s)
{
DP[lc][s] = DP[la][s]; /// am pus un 0
if(s >= i*j) /// avem de unde aduna
DP[lc][s] = DP[lc][s] + DP[la][s-i*j]; /// am pus un 1;
DP[lc][s] = DP[lc][s] + DP[la][s+i*j]; /// am pus un -1
while(DP[lc][s] > 10000)
DP[lc][s] -= 10000;
}
lc ^= 1;
la ^= 1;
}
if(K > sup_limit || K < down_limit )printf("0\n");
else printf("%d\n",DP[la][K + sup_limit]);
return 0;
}