Pagini recente » Cod sursa (job #2664901) | Cod sursa (job #3187302) | Cod sursa (job #3293125) | Cod sursa (job #3158780) | Cod sursa (job #3196178)
#include <iostream>
#include <bits/stdc++.h>
#include <fstream>
using namespace std;
ifstream fin("stirling.in");
ofstream fout("stirling.out");
int n,x,y,t,tip;
const int nmax = 210,kmax = 210,MOD = 98999;
vector<vector<long long int>> stirling1(nmax+1,vector<long long int>(kmax+1)),stirling2(nmax+1,vector<long long int>(kmax+1));
void precalculare(){
stirling1[0][0] = stirling2[0][0] = 1;
for(int i = 1; i <=nmax; i++){
for(int j = 1; j <= min(i,kmax); j++){
stirling1[i][j] = (stirling1[i-1][j-1] - (i-1)*stirling1[i-1][j]%MOD)%MOD;
}
}
for(int i = 1; i <=nmax; i++){
for(int j = 1; j <= min(i,kmax); j++){
stirling2[i][j] = (stirling2[i-1][j-1] + j*stirling2[i-1][j]%MOD)%MOD;
}
}
};
void solve(){
fin >> tip >> x >> y;
if(tip == 1){
fout << stirling1[x][y] << '\n';
}else{
fout << stirling2[x][y] << '\n';}
}
int main()
{
fin >> t;
precalculare();
while(t--){
solve();
}
}