Pagini recente » Cod sursa (job #1105828) | Cod sursa (job #1625930) | Cod sursa (job #1155811) | Cod sursa (job #2814426) | Cod sursa (job #2054806)
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin("stirling.in");
ofstream fout("stirling.out");
const int NMAX = 200 + 5;
const int MOD = 98999;
int teste, cod, x, y;
int sp1[NMAX][NMAX], sp2[NMAX][NMAX];
int speta1(int n, int m)
{
sp1[1][1] = 1;
for (int i = 2; i <= n; ++i)
for (int j = 1; j <= i; ++j)
sp1[i][j] = (sp1[i - 1][j - 1] - (i - 1) * sp1[i - 1][j]) % MOD;
}
int speta2(int n, int m)
{
sp2[1][1] = 1;
for (int i = 2; i <= n; ++i)
for (int j = 1; j <= i; ++j)
sp2[i][j] = (sp2[i - 1][j - 1] + j * sp2[i - 1][j]) % MOD;
}
int main()
{
fin >> teste;
speta1(NMAX - 2, NMAX - 2);
speta2(NMAX - 2, NMAX - 2);
while (teste--)
{
fin >> cod >> x >> y;
if (cod == 1)
fout << sp1[x][y] << '\n';
else
fout << sp2[x][y] << '\n';
}
return 0;
}