Cod sursa(job #3253011)

Utilizator ax_dogaruDogaru Alexandru ax_dogaru Data 31 octombrie 2024 20:00:02
Problema Diamant Scor 100
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.7 kb
#include <bits/stdc++.h>

using namespace std;

ifstream fin("diamant.in");
ofstream fout("diamant.out");

int dp[2][91000];

int main()
{
    int n, m, x, val, id=1, smax=45000;
    fin >> n >> m >> x;
    dp[0][smax]=1;
    for(int i=1; i<=n; i++) {
        for(int j=1; j<=m; j++) {
            val=i*j;
            for(int k=0; k<=2*smax; k++) {
                dp[id][k]=(dp[1-id][k-val]+dp[1-id][k+val]+dp[1-id][k])%10000;
            }
            id=1-id;
        }
    }
    /*for(int i=0; i<=18; i++) {
        cout << dp[1-id][i+smax] << " ";
    }*/
    if(x>smax || x<-1*smax) {
        fout << "0";
    } else {
        fout << dp[1-id][x+smax];
    }
    return 0;
}