Pagini recente » Cod sursa (job #2965400) | Cod sursa (job #2271530) | Cod sursa (job #2890394) | Cod sursa (job #2548369) | Cod sursa (job #2768440)
#include <fstream>
using namespace std;
const int MOD = 98999;
const int NMAX = 200;
ifstream fin("stirling.in");
ofstream fout("stirling.out");
int dp_speta1[NMAX + 5][NMAX + 5];
int dp_speta2[NMAX + 5][NMAX + 5];
int main()
{
ios_base::sync_with_stdio(false);
fin.tie(NULL);
int t,i,j,sp,x,y;
fin >> t;
dp_speta1[1][1] = dp_speta2[1][1] = 1;
for(i = 2; i <= NMAX; i++)
for(j = 1; j <= i; j++)
{
dp_speta1[i][j] = (dp_speta1[i - 1][j - 1] - (i - 1) * dp_speta1[i - 1][j]) % MOD;
dp_speta2[i][j] = (dp_speta2[i - 1][j - 1] + j * dp_speta2[i - 1][j]) % MOD;
}
while(t--)
{
fin >> sp >> x >> y;
if(sp == 1)
fout << dp_speta1[x][y] << "\n";
else
fout << dp_speta2[x][y] << "\n";
}
return 0;
}