Pagini recente » Cod sursa (job #2821328) | Cod sursa (job #2795340) | Cod sursa (job #1561777) | Cod sursa (job #2389541) | Cod sursa (job #2667800)
#include <cstdio>
using namespace std;
#define MAXN 202
#define MOD 98999
int type_1[MAXN][MAXN], type_2[MAXN][MAXN];
void precalculate_type_1() {
type_1[1][1] = 1;
for(int i=2; i<MAXN; ++i)
for(int j = 1; j<=i; ++j)
type_1[i][j] = (type_1[i-1][j-1] - (i-1) * type_1[i-1][j]) % MOD;
}
void precalculate_type_2() {
type_2[1][1] = 1;
for(int i=2; i<MAXN; ++i)
for(int j = 1; j<=i; ++j)
type_2[i][j] = (type_2[i-1][j-1] - j * type_2[i-1][j]) % MOD;
}
int main() {
freopen("stirling.in", "r", stdin);
freopen("stirling.out", "w", stdout);
int n, type, a, b;
precalculate_type_1();
precalculate_type_2();
scanf("%d", &n);
for(int i=1; i<=n; ++i) {
scanf("%d%d%d", &type, &a, &b);
if (type == 1)
printf("%d\n", type_1[a][b]);
else
printf("%d\n", type_2[a][b]);
}
return 0;
}