Pagini recente » Cod sursa (job #1116104) | Cod sursa (job #1421165) | Cod sursa (job #524599) | Cod sursa (job #2046835) | Cod sursa (job #2286478)
#include <iostream>
#include <fstream>
#define R 98999
using namespace std;
ifstream f("stirling.in");
ofstream g("stirling.out");
int stir2[203][203],i,j,n;
int stir1[203][203];
int main()
{
f>>n;
stir2[0][0]=1;
stir1[0][0]=1;
for(i=1;i<=200;i++)
for(j=1;j<=i;j++)
{
stir2[i][j]=(stir2[i-1][j-1]+j*stir2[i-1][j])%R;
stir1[i][j]=(stir1[i-1][j-1]-(n-1)*stir1[i-1][j])%R;
}
for(i=1;i<=n;i++)
{
int speta,x,y;
f>>speta>>x>>y;
if(speta==2)
g<<stir2[x][y]<<'\n';
else g<<stir1[x][y]<<'\n';
}
}