Pagini recente » Cod sursa (job #1177250) | Cod sursa (job #1040871) | Cod sursa (job #1072126) | Cod sursa (job #2864722) | Cod sursa (job #2973305)
#include <fstream>
#include <vector>
using namespace std;
ifstream fin("stirling.in");
ofstream fout("stirling.out");
const int Nmax = 201, MOD = 98999;
vector <vector <int>> speta2(Nmax, vector <int> (Nmax)), speta1(Nmax, vector <int> (Nmax));
void calc2()
{
int i, j;
speta2[0][0] = 1;
for(i = 1; i < Nmax; i++)
for(j = 1; j < Nmax; j++)
speta2[i][j] = (speta2[i - 1][j - 1] + j * speta2[i - 1][j]) % MOD;
}
void calc1()
{
int i, j;
speta1[1][1]= 1;
for(i = 2; i < Nmax; i++)
for(j = 1; j <= i; j++)
speta1[i][j]= (speta1[i - 1][j - 1] - (i - 1) * speta1[i - 1][j]) % MOD ;
}
int main()
{
int t, n, k;
calc1(), calc2();
fin >> t;
for(int i = 1; i <= t; i++)
{
int tip;
fin >> tip >> n >> k;
if(tip == 2)
fout << speta2[n][k];
else
fout << speta1[n][k];
fout << '\n';
}
return 0;
}