Pagini recente » Cod sursa (job #94635) | Cod sursa (job #2481434) | Cod sursa (job #3277107) | Cod sursa (job #1668362) | Cod sursa (job #185710)
Cod sursa(job #185710)
#include<stdio.h>
int n,m,st[1000],top,nr=0;;
long long x;
long long sum=0;
long long evalid(int top)
{
int i;
long long s=0;
for(i=1;i<=top;i++)
{
if(i%m==0)
s+=st[i]*(i/m)*m;
else
s+=st[i]*(i/m+1)*(i%m);
}
return s;
}
int main()
{
int cand;
freopen("diamant.in","r",stdin);
freopen("diamant.out","w",stdout);
scanf("%d %d %lld",&n,&m,&x);
top=1;
st[top]=-2;
while(top>0)
{
cand=0;
if(st[top]<=1)
st[top]++;
if(st[top]>1)
top--;
else
if((top==n*m))
{
if((evalid(top)==x))
nr=(nr+1)%10000;
}
else
st[++top]=-2;
}
printf("%d\n",nr);
return 0;
}