Pagini recente » Cod sursa (job #613097) | Cod sursa (job #1538723) | Cod sursa (job #2662711) | Cod sursa (job #799784) | Cod sursa (job #626489)
Cod sursa(job #626489)
# include<stdio.h>
long v1[202][202], v2[202][202],i,j,op,n,k,p;
int main()
{
freopen("stirling.in","r",stdin);
freopen("stirling.out","w",stdout);
scanf("%d\n",&n);
v1[0][0]=1; v2[0][0]=1;
for (i=1; i<=201; i++)
{
v1[i][0]=0;
v1[i][i]=1;
v2[i][0]=0;
v2[i][i]=1;
}
for (i=1; i<=201; i++)
for (j=1; j<=201; j++)
if (i!=j)
{
v1[i][j]=(v1[i-1][j-1]-(i-1)*v1[i-1][j])%98999;
v2[i][j]=(v2[i-1][j-1]+j*v2[i-1][j])%98999;
}
for (i=1; i<=n; i++)
{
scanf("%ld %ld %ld\n",&op,&p,&k);
if (op==1)
{
printf("%ld\n",v1[p][k]);
}
else
printf("%ld\n",v2[p][k]);
}
return 0;
}