Pagini recente » Cod sursa (job #858721) | Cod sursa (job #434339) | Cod sursa (job #2377205) | Cod sursa (job #549088) | Cod sursa (job #2063859)
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin("stirling.in");
ofstream fout("stirling.out");
const int NMax=205;
const int MOD=98999;
int T,N,M,p,DP[NMax][NMax],dp[NMax][NMax];
void Solve1()
{
DP[1][1]=1;
dp[1][1]=1;
for(int i=2;i<=200;++i)
{
for(int j=1;j<=200;++j)
{
DP[i][j]=DP[i-1][j-1]-(i-1)*DP[i-1][j];
DP[i][j]=DP[i][j]%MOD;
dp[i][j]=dp[i-1][j-1]+j*dp[i-1][j];
dp[i][j]=dp[i][j]%MOD;
}
}
}
int main()
{
fin>>T;
Solve1();
while(T--)
{
fin>>p>>N>>M;
if(p==1)
{
fout<<DP[N][M]<<"\n";
}
if(p==2)
{
fout<<dp[N][M]<<"\n";
}
}
return 0;
}