Pagini recente » Cod sursa (job #1575397) | Cod sursa (job #1644857) | Cod sursa (job #2044974) | Cod sursa (job #263205) | Cod sursa (job #3204139)
#include <iostream>
#include <fstream>
using namespace std;
ifstream f("stirling.in");
ofstream g("stirling.out");
long long stir1[205][205],stir2[205][205],t,x,n,m,i;
void speta1()
{stir1[0][0]=1;
for(int i=1;i<=201;i++)
for(int j=1;j<=201;j++)
stir1[i][j]=stir1[i-1][j-1]-(i-1)*stir1[i-1][j];
}
void speta2()
{stir2[0][0]=1;
for (int i=1;i<=201;i++)
for (int j=1;j<=201;j++)
stir2[i][j]=stir2[i-1][j-1]+j*stir2[i-1][j];
}
int main()
{f>>t;
speta1();
speta2();
for(i=1;i<=t;i++)
{f>>x>>n>>m;
if(x==1)g<<stir1[n][m]<<'\n';
else g<<stir2[n][m]<<'\n';
}
}