Cod sursa(job #2137338)

Utilizator dumitrescugeorgeGeorge Dumitrescu dumitrescugeorge Data 20 februarie 2018 18:56:41
Problema Diamant Scor 10
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.74 kb
#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;
int n,m,x,v[405],k=0;
int dr[2][88800];
void citire()
{
    scanf("%d%d%d",&n,&m,&x);
      for(int i=1; i<=n; ++i)
        for(int j=1; j<=m; ++j)
        {
            v[++k]=i*j;
            dr[0][v[k]]++;
        }
    int l = 1;
    int x=n*(n+1)/2;
    int y=m*(m+1)/2;
    for(int i=1; i<=n*m; ++i)
    {
        for(int j=v[i]; j<=x*y+v[i];j++)
        {
            dr[l][j]+=dr[1-l][j-v[i]]+dr[1-l][j+v[i]];
            dr[l][j]=dr[l][j]%10000;
        }
        l=1-l;
    }
    printf("%d",dr[0][x]%10000);
}
int main()
{
    freopen("diamant.in","r",stdin);
    freopen("diamant.out","w",stdout);
    citire();
    return 0;
}