Pagini recente » Cod sursa (job #1700798) | Cod sursa (job #3216477) | Cod sursa (job #897518) | Cod sursa (job #684175) | Cod sursa (job #2696574)
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin("stirling.in");
ofstream fout("stirling.out");
long long s[205][205],S[205][205];
void speta_1()
{
S[0][0] = 1;
for(int i = 1; i < 201;i++)
for(int j = 1; j < 201; j++)
{
S[i][j] =(1-i)*S[i-1,j] + S[i-1,j-1];
S[i][j] = S[i][j] % 98999;
}
}
void speta_2()
{
s[0][0] = 1;
for(int i = 1; i < 201;i++)
for(int j = 1; j < 201; j++)
{
s[i][j] = j * s[i - 1,j] + s[i - 1, j - 1];
s[i][j] = s[i][j] % 98999;
}
}
int main()
{
long long t,n,m,x;
fin >> t;
speta_1();
speta_2();
for(int i = 0; i < t; i++)
{
fin >> x >> n >> m;
if( x == 1)
fout << S(n,m) << "\n";
else
fout << s(n,m) << "\n";
}
return 0;
}