Cod sursa(job #2108790)

Utilizator smashsmash everything smash Data 18 ianuarie 2018 20:17:58
Problema Diamant Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 1.32 kb
#include <fstream>

using namespace std;
ifstream cin ("diamant.in");
ofstream cout ("diamant.out");
int best[101000],cop[101000];
long long n,m,x,k=0;
#define best (best+50210)
#define cop (cop+50210)
void read ()
{
    cin>>n>>m>>x;
    best[0]=1;
}
void up_date (int val)
{
    for(int i=44100-val;i>=-44100;i--)
        cop[i+val]=(best[i+val]+best[i])%10000;
        for(int i=-44100;i<-44100+val;i++) cop[i]=best[i];
}
void up_date_d (int val)
{
    for(int i=-44100-val;i<=44100;i++)
        cop[i+val]=(cop[i+val]+best[i])%10000;
}
void up_date2 (int val)
{
    for(int i=44100-val;i>=-44100;i--)
        best[i+val]=(cop[i+val]+cop[i])%10000;
        for(int i=-44100;i<-44100+val;i++) best[i]=cop[i];
}
void up_date_d2 (int val)
{
    for(int i=-44100-val;i<=44100;i++)
        best[i+val]=(best[i+val]+cop[i])%10000;
}
void solve ()
{ int val;
    for(int i=1;i<=n;i++)
    for(int j=1;j<=m;j++)
    { ++k;
        val=i*j;
        if(k%2!=0) {
        up_date(val);
        up_date_d(val*-1); }
        else
        {
             up_date2(val);
            up_date_d2(val*-1); }
    }
    if(k%2==0) cout<<best[x]; else cout<<cop[x];
}
int main()
{
    read();
    if(x>44100 || x<-44100) {cout<<0; return 0;}
    solve();
    cin.close();
    cout.close();
    return 0;
}