Pagini recente » Cod sursa (job #1752428) | Cod sursa (job #1447152) | Cod sursa (job #1760077) | Cod sursa (job #2977070) | Cod sursa (job #662884)
Cod sursa(job #662884)
#include<fstream>
# define mod 98999;
using namespace std;
long ipc,a,b,i,j,stir[222][222],st[222][222],n;
int main(){
ifstream f("stirling.in");
ofstream g("stirling.out");
f>>n;
stir[0][0]=1;
st[0][0]=1;
for (i=1;i<220;i++){
stir[1][1]=0;
st[i][i]=1;
stir[i][0]=0;
st[i][0]=0;
}
for (i=1;i<=220;i++)
for (j=1;j<=220;j++){
stir[i][j]=(stir[i-1][j-1]-((i-1)*stir[i-1][j])) % mod;
st[i][j]=(st[i-1][j-1]+(j*st[i-1][j])) % mod;
}
for (i=1;i<=n;i++){
f>>ipc>>a>>b;
if (ipc==1) g<<stir[a][b]<<"\n";
else g<<st[a][b]<<"\n";
}
return 0;
}