Pagini recente » Cod sursa (job #3293508) | Cod sursa (job #3190080) | Cod sursa (job #21575) | Cod sursa (job #3241958) | Cod sursa (job #471672)
Cod sursa(job #471672)
#include <stdio.h>
#define N 201
#define mod 98999
int mat[N][N];
int mat2[N][N];
int main()
{freopen("stirling.in","r",stdin);
freopen("stirling.out","w",stdout);
int t,i,j,x,n,m;
scanf("%d",&t);
mat[0][0]=1;
mat2[0][0]=1;
for (j=1;j<N;j++)
{mat[j][j]=1;
mat2[j][j]=1;
for (i=j+1;i<N;i++)
{mat[i][j]=(mat[i-1][j-1]-(i-1)*mat[i-1][j])%mod;
mat2[i][j]=(mat2[i-1][j-1]+j*mat2[i-1][j])%mod;
}
}
/*
for (i=1;i<=5;i++)
{for (j=1;j<=5;j++)
{printf("%d ",mat2[i][j]);
}
printf("\n");
}*/
for (i=1;i<=t;i++)
{scanf("%d %d %d",&x,&n,&m);
if(x==1)
{printf("%d\n",mat[n][m]);
}
else
{printf("%d\n",mat2[n][m]);
}
}
return 0;
}