Pagini recente » Cod sursa (job #3199598) | Cod sursa (job #1577203) | Cod sursa (job #2963028) | Cod sursa (job #2780432) | Cod sursa (job #1459474)
#include <fstream>
#define MOD 98999
using namespace std;
ifstream fin ("stirling.in");
ofstream fout ("stirling.out");
int T, tip, n, k;
int DP[3][210][210];
void Precalcul_Stirling_I()
{
DP[1][1][1] = 1;
for (int i = 2; i <= 200; i++)
{
for (int j = 1; j <= 200; j++)
{
DP[1][i][j] = (DP[1][i - 1][j - 1] - (i - 1) * DP[1][i - 1][j]) % MOD;
}
}
}
void Precalcul_Stirling_II()
{
DP[2][1][1] = 1;
for (int i = 2; i <= 200; i++)
{
for (int j = 1; j <= 200; j++)
{
DP[2][i][j] = (DP[2][i - 1][j - 1] + j * DP[2][i - 1][j]) % MOD;
}
}
}
int main()
{
Precalcul_Stirling_I();
Precalcul_Stirling_II();
fin >> T;
while (T--)
{
fin >> tip >> n >> k;
fout << DP[tip][n][k] << '\n';
}
return 0;
}