Pagini recente » Cod sursa (job #571103) | Cod sursa (job #1289975) | Cod sursa (job #394819) | Cod sursa (job #895652) | Cod sursa (job #2588577)
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin("stirling.in");
ofstream fout("stirling.out");
const int nmax=205;
const int mmax=205;
const int mo=98999;
long long dp1[nmax+5][mmax+5],dp2[nmax+5][mmax+5];
void stirling2()
{
dp2[0][0]=1;
for(int i=1;i<=nmax;i++)
for(int j=1;j<=i;j++)
dp2[i][j]=dp2[i-1][j-1]%mo+(1LL*j*dp2[i-1][j])%mo;
}
void stirling1()
{
dp1[0][0]=1;
for(int i=1;i<=nmax;i++)
for(int j=1;j<=i;j++)
dp1[i][j]=dp1[i-1][j-1]%mo-(1LL*(i-1)*dp1[i-1][j])%mo;
}
int main()
{
int t;
fin>>t;
stirling2();
stirling1();
while(t--)
{
int x,n,m;
fin>>x>>n>>m;
if(x==2)
fout<<dp2[n][m]%mo<<"\n";
else
fout<<dp1[n][m]%mo<<"\n";
}
return 0;
}