Mai intai trebuie sa te autentifici.
Cod sursa(job #1698042)
Utilizator | Data | 3 mai 2016 15:41:31 | |
---|---|---|---|
Problema | Diamant | Scor | 30 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.9 kb |
#include <iostream>
#include<fstream>
using namespace std;
int v[90005],aux[90005],i,j,n,m,x,k,c,i1,nmax,fix;
int main()
{
ifstream f("diamant.in");
ofstream g("diamant.out");
f>>n>>m>>x;
for(i=1;i<=n;i++)
for(j=1;j<=m;j++)
nmax+=i*j;
if(x>nmax||x<(-nmax)) {g<<'0';return 0;}
v[0]=1;
aux[0]=1;
for(i=1;i<=n;i++)
for(j=1;j<=m;j++)
{
k=i*j;
fix=2*nmax-k;
for(i1=fix;i1>=0;i1--)
{
v[i1+k]+=aux[i1];
v[i1]%=10000;
}//pt 0
k*=2;
fix=2*nmax-k;
for(i1=fix;i1>=0;i1--)
{
v[i1+k]+=aux[i1];
v[i1]%=10000;
}//pt +
for(i1=0;i1<=2*nmax;i1++) aux[i1]=v[i1];
}
g<<v[x+nmax];
return 0;
}