Pagini recente » Cod sursa (job #2133538) | Cod sursa (job #595658) | Cod sursa (job #2624578) | Cod sursa (job #891401) | Cod sursa (job #2070900)
#include <bits/stdc++.h>
using namespace std;
ifstream fin("stirling.in");
ofstream fout("stirling.out");
#define lim 203
#define mod 98999
int stir1[lim][lim], stir2[lim][lim];
int x,n,m,t;
int main()
{
fin>>t;
stir1[1][1] = 1;
stir2[1][1] = 1;
for (int i=1; i<=lim-2; i++)
for (int j=1; j<=lim-2; j++)
{
if (i==1 && j==1)
continue;
stir1[i][j] = stir1[i - 1][j - 1] - (i - 1) * stir1[i - 1][j];
stir1[i][j] %= mod;
stir2[i][j] = stir2[i - 1][j - 1] + j * stir2[i - 1][j];
stir2[i][j] %= mod;
}
while(t--)
{
fin>>x>>n>>m;
if(x == 1)
fout<<stir1[n][m]<<'\n';
else
fout<<stir2[n][m]<<'\n';
}
return 0;
}