Pagini recente » Cod sursa (job #1639255) | Cod sursa (job #1551690) | Cod sursa (job #2682291) | Cod sursa (job #2068159) | Cod sursa (job #1558939)
#include <cstdio>
using namespace std;
const int n = 201 , modulo = 98999 ;
int s[202][202] , S[202][202] , i , j ;
void s_mic()
{
s[1][1] = 1 ;
for ( i = 2 ; i < n ; i++ )
{
for ( j = 1 ; j <= i ; j++ )
{
s[i][j] = ( s[i-1][j-1] - ( i - 1 ) * s[i-1][j] ) % modulo ;
}
}
}
void S_mare()
{
S[1][1] = 1 ;
for ( i = 2 ; i < n ; i++ )
{
for ( j = 1 ; j <= i ; j++ )
{
S[i][j] = ( S[i-1][j-1] + j * S[i-1][j] ) % modulo ;
}
}
}
int main()
{
freopen("stirling.in","r",stdin);
freopen("stirling.out","w",stdout);
int x , y , speta , t;
s_mic();
S_mare();
scanf("%d",&t);
for ( int h = 1 ; h <= t ; h++ )
{
scanf("%d %d %d",&speta,&x,&y) ;
{
if ( speta == 1 )
{
printf("%d\n",s[x][y]);
}
if ( speta == 2 )
{
printf("%d\n",S[x][y]);
}
}
}
return 0 ;
}