Cod sursa(job #2108780)

Utilizator smashsmash everything smash Data 18 ianuarie 2018 20:09:38
Problema Diamant Scor 80
Compilator cpp Status done
Runda Arhiva de probleme Marime 1.3 kb
#include <fstream>

using namespace std;
ifstream cin ("diamant.in");
ofstream cout ("diamant.out");
int best[100010],cop[101001];
long long n,m,x,k=0;
#define best (best+50001)
#define cop (cop+50001)
void read ()
{
    cin>>n>>m>>x;
    best[0]=1;
}
void up_date (int val)
{
    for(int i=45000-val;i>=-45000;i--)
        cop[i+val]=(best[i+val]+best[i])%10000;
        for(int i=-45000;i<-45000+val;i++) cop[i]=best[i];
}
void up_date_d (int val)
{
    for(int i=-45000+val;i<=45000;i++)
        cop[i+val]=(cop[i+val]+best[i])%10000;
}
void up_date2 (int val)
{
    for(int i=45000-val;i>=-45000;i--)
        best[i+val]=(cop[i+val]+cop[i])%10000;
        for(int i=-45000;i<-45000+val;i++) best[i]=cop[i];
}
void up_date_d2 (int val)
{
    for(int i=-45000+val;i<=45000;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); }
    }
    cout<<max(best[x],cop[x]);
}
int main()
{
    read();
    if(x>45000 || x<-45000) {cout<<0; return 0;}
    solve();
    cin.close();
    cout.close();
    return 0;
}