Pagini recente » Cod sursa (job #2840476) | Cod sursa (job #2485857) | Cod sursa (job #906231) | Cod sursa (job #2028060) | Cod sursa (job #2973289)
#include <fstream>
using namespace std;
int mat1[205][205],mat2[205][205];
int main()
{
ifstream fin("stirling.in");
ofstream fout("stirling.out");
int mod=98999;
mat1[1][1]=1;
for(int i=2;i<=200;i++){
for(int j=1;j<=i;j++){
mat1[i][j]=(mat1[i-1][j-1]-(i-1)*mat1[i-1][j])%mod;
}
}
mat2[1][1]=1;
for(int i=2;i<=200;i++){
for(int j=1;j<=i;j++){
mat2[i][j]=(mat2[i-1][j-1]+j*mat2[i-1][j])%mod;
}
}
int t,x,n,m;fin>>t;
for(int i=1;i<=t;i++){
fin>>x>>n>>m;
if(x==1){
fout<<mat1[n][m]<<'\n';
}
else{
fout<<mat2[n][m]<<'\n';
}
}
return 0;
}