Pagini recente » Cod sursa (job #2355750) | Cod sursa (job #2036336) | Cod sursa (job #247387) | Cod sursa (job #799981) | Cod sursa (job #1533492)
#include <fstream>
using namespace std;
#define Mod 98999
int s[201][201], S[201][201];
void Stirling_Speta_I(int n,int m)
{
s[1][1] = 1;
for (int i = 2; i <= n; i++)
for (int j = 1; j <= i; j++)
s[i][j] = (s[i-1][j-1] - (i-1)*s[i-1][j]) % Mod;
}
void Stirling_Speta_II(int n,int m)
{
S[1][1] = 1;
for (int i = 2; i <= n; i++)
for (int j = 1; j <= i; j++)
S[i][j] = (S[i-1][j-1] + j * S[i-1][j]) % Mod;
}
int main()
{
ifstream fin("stirling.in");
ofstream fout("stirling.out");
Stirling_Speta_I(200,200);
Stirling_Speta_II(200,200);
int t;
fin >> t;
while (t--)
{
int a,b,c;
fin >> a >> b >> c;
if (a == 1)
fout << s[b][c] << "\n";
else fout << S[b][c] << "\n";
}
}