Pagini recente » Cod sursa (job #2976627) | Cod sursa (job #2829023) | Cod sursa (job #2745300) | Cod sursa (job #2438507) | Cod sursa (job #2437473)
#include <iostream>
#include <fstream>
using namespace std;
void calculare_1(int s[210][210]){
s[1][1] = 1;
for(int i = 2; i <= 200; i++){
for(int j = 1; j<=i; j++){
s[i][j] = ( s[i-1][j-1] - (i-1)*s[i-1][j])%98999;
}
}
}
void calculare_2(int S[210][210]){
S[1][1] = 1;
for(int i = 2; i <= 210; i++){
for(int j = 1; j<=i; j++){
S[i][j] = ( S[i-1][j-1] + j*S[i-1][j])%98999;
}
}
}
int main(){
int n, m, x, t, s[210][210], S[210][210];
ifstream fin("stirling.in");
ofstream fout("stirling.out");
fin >> t;
calculare_1(s);
calculare_2(S);
for(int i = 0; i < t; i++){
fin >> x >> n >> m;
if(x == 1){
fout << s[n][m] << '\n';
}
if(x == 2){
fout << S[n][m] << '\n';
}
}
return 0;
}