Pagini recente » Cod sursa (job #2724979) | Cod sursa (job #320829) | Cod sursa (job #1671331) | Cod sursa (job #672094) | Cod sursa (job #3204140)
#include <iostream>
#include <fstream>
using namespace std;
ifstream f("stirling.in");
ofstream g("stirling.out");
long long stir1[205][205],stir2[205][205],t,x,n,m,i;
void speta1()
{stir1[0][0]=1;
for(int i=1;i<=201;i++)
for(int j=1;j<=i;j++)
stir1[i][j]=(stir1[i-1][j-1]-(i-1)*stir1[i-1][j])%98999;
}
void speta2()
{stir2[0][0]=1;
for (int i=1;i<=201;i++)
for (int j=1;j<=i;j++)
stir2[i][j]=(stir2[i-1][j-1]+j*stir2[i-1][j])%98999;
}
int main()
{f>>t;
speta1();
speta2();
for(i=1;i<=t;i++)
{f>>x>>n>>m;
if(x==1)g<<stir1[n][m]<<'\n';
else g<<stir2[n][m]<<'\n';
}
}