Pagini recente » Cod sursa (job #1160515) | Cod sursa (job #2611742) | Cod sursa (job #2937161) | Cod sursa (job #1721467) | Cod sursa (job #205927)
Cod sursa(job #205927)
#include <stdio.h>
#define NMAX 256
#define M 194767
int din[2][NMAX*NMAX];
int K,N,S;
int main()
{
freopen("1-sir.in","r",stdin);
freopen("1-sir.out","w",stdout);
int i,j,x;
scanf("%d %d",&N,&S);
if (S<0) S*=-1;
if ( S>(N*N-1)/2 ) {printf("0");return 0;}
K=N*(N-1)/2 - S;
if (K%2==1) {printf("0");return 0;}
K/=2;
// printf("%d ",K);
din[0][0]=1;
for (i=1,x=0;i<N;i++)
{
x=!x;
for (j=0;j<=K;j++)
{
din[x][j]=din[!x][j];
if (j>=i) din[x][j]+=din[!x][j-i];
din[x][j]%=M;
}
}
printf("%d",din[x][K]);
return 0;
}