Cod sursa(job #994640)

Utilizator harababurelPuscas Sergiu harababurel Data 5 septembrie 2013 23:09:02
Problema Diamant Scor 20
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.79 kb
#include <iostream>
#include <fstream>
#define vmax 45000
#define smax 46000
#define mod 10000
using namespace std;

int n, m, x;
short cur[2*smax], pre[2*smax];
#define cur (cur+smax)
#define pre (pre+smax)


int main() {
    ifstream f("diamant.in");
    ofstream g("diamant.out");

    f>>n>>m;
    f>>x;

    for(int i=1; i<=n; i++) {
        for(int j=1; j<=m; j++) {
            for(int val=-vmax; val<=vmax; val++)
                cur[val] = pre[val] + pre[val-i*j] + pre[val+i*j];

            cur[i*j]++;
            cur[-i*j]++;

            for(int val=-vmax; val<=vmax; val++) pre[val] = cur[val] % mod;
        }
    }



    //for(int i=1; i<=x; i++) cout<<cur[i]<<" "; cout<<"\n\n";
    //cout<<cur[x]<<"\n";
    g<<cur[x]<<"\n";



    return 0;
}