Pagini recente » Cod sursa (job #2350091) | Cod sursa (job #2475876) | Cod sursa (job #1285393) | Istoria paginii preoji2016/clasament/9 | Cod sursa (job #3157372)
#include <fstream>
#include <algorithm>
using namespace std;
ifstream fin("stirling.in");
ofstream fout("stirling.out");
int n, st[220][220], stsp2[220][220], m, t, x, mod=98999;
void stirling()
{
for (int i=2; i<=200; i++)
{
for (int j=1; j<=i; j++)
{
st[i][j]=(st[i-1][j-1]-(i-1)*st[i-1][j])%mod;
}
}
}
void stirlingspII()
{
for (int i=2; i<=200; i++)
{
for (int j=1; j<=i; j++)
{
stsp2[i][j]=(stsp2[i-1][j-1]+j*stsp2[i-1][j])%mod;
}
}
}
int main()
{
st[1][1]=1;
stsp2[1][1]=st[1][1];
fin >> t;
stirling();
stirlingspII();
for (int i=1; i<=t; i++)
{
fin >> x >> n >> m;
if (x==1)
{
fout << st[n][m] << '\n';
}
else fout << stsp2[n][m] << '\n';
}
fin.close();
fout.close();
return 0;
}