Pagini recente » Cod sursa (job #31999) | Cod sursa (job #3281304) | Cod sursa (job #1914762) | Cod sursa (job #1367410) | Cod sursa (job #580177)
Cod sursa(job #580177)
#include<fstream>
#include<math.h>
#define dmax 50000
#define nmax 23
#define mod 10000
using namespace std;
ifstream in("diamant.in");
ofstream out("diamant.out");
int n,m,s,x,nr,a[dmax],b[dmax];
int main()
{
int i,j,k;
in>>n>>m>>s;
in.close();
for(i=1;i<=n;i++)
for(j=1;j<=m;j++)
nr += (i*j);
if(s > nr || s < -nr)
out<<"0\n";
else
{
b[0] = 1;
b[1] = 1;
for(i=1;i <= n;i++)
for(j=1;j <= m; j++)
if(i*j != 1)
{
for(k=0; k<=nr; k++)
{
a[k] += b[k];
if(k - i*j < 0)
a[k] += b[i*j - k];
else a[k] += b[k-i*j];
a[k] += b[i*j+k];
if(a[k] >= mod)
a[k] %= mod;
}
for(k=0;k<=nr;k++)
{ b[k] = a[k];
a[k] = 0;
}
}
out<<b[abs(s)]<<'\n';
}
out.close();
return 0;
}