Pagini recente » Cod sursa (job #2902151) | Cod sursa (job #2512072) | Cod sursa (job #2473858) | Cod sursa (job #2584295) | Cod sursa (job #1944613)
#include <fstream>
using namespace std;
#define nmax 210
#define mod 98999
ifstream f("stirling.in");
ofstream g("stirling.out");
int i,j,s[nmax][nmax],S[nmax][nmax];
void construiestes()
{
s[1][1]=1;
for(i=2;i<nmax;i++)
for(j=1;j<=i;j++)
s[i][j]=(s[i-1][j-1]-(i-1)*s[i-1][j])%mod;
}
void construiesteS()
{
S[1][1]=1;
for(i=2;i<nmax;i++)
for(j=1;j<=i;j++)
S[i][j]=(S[i-1][j-1]+j*S[i-1][j])%mod;
}
int main()
{
int t,q,tip,x,y;
construiestes();
construiesteS();
f>>t;
for(q=1;q<=t;q++)
{
f>>tip>>x>>y;
if(tip==1)
g<<s[x][y];
else
g<<S[x][y];
g<<'\n';
}
return 0;
}