Pagini recente » Cod sursa (job #3240910) | Cod sursa (job #265010) | Cod sursa (job #2814598) | Cod sursa (job #400139) | Cod sursa (job #471670)
Cod sursa(job #471670)
#include <stdio.h>
#define N 201
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];
mat2[i][j]=mat2[i-1][j-1]+j*mat2[i-1][j];
}
}
/*
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;
}