Pagini recente » Cod sursa (job #2350892) | Cod sursa (job #1111565) | Cod sursa (job #2382021) | Cod sursa (job #2287068) | Cod sursa (job #1418428)
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin("stirling.in");
ofstream fout("stirling.out");
const int NMax = 205;
const int MOD = 98999;
long long int A[NMax][NMax],B[NMax][NMax];
void make_stirling(){
A[1][1] = B[1][1] = 1;
for(int i = 2; i <= 200; i++){
for(int j = 1; j <= i; j++){
A[i][j] = (A[i - 1][j - 1] - (i - 1) * A[i - 1][j] % MOD) % MOD;
}
}
for(int i = 2; i <= 200; i++){
for(int j = 1; j <= i; j++){
B[i][j] = (B[i - 1][j - 1] + j * B[i - 1][j] % MOD) % MOD;
}
}
}
int main()
{
int t,x,n,m;
fin >> t;
make_stirling();
while(t--){
fin >> x >> n >> m;
if(x == 1){
fout << A[n][m] << "\n";
} else {
fout << B[n][m] << "\n";
}
}
return 0;
}