Pagini recente » Rezultatele filtrării | Cod sursa (job #3270383) | Cod sursa (job #860230) | Cod sursa (job #1975649) | Cod sursa (job #2973310)
#include <fstream>
using namespace std;
ifstream fin("stirling.in");
ofstream fout("stirling.out");
int a[202][202];
int b[202][202];
int const n = 200;
const int MOD = 98999;
void speta1()
{
int i,j;
a[1][1] = 1;
for(i=2;i<n;++i)
{
for(j=1;j<=i;++j)
{
a[i][j] = (a[i-1][j-1] - (i-1) *a[i-1][j])%MOD;
}
}
}
void speta2()
{
int i,j;
b[1][1] = 1;
for(i=2;i<=n;++i)
{
for(j=1;j<=i;++j)
{
b[i][j] = (b[i-1][j -1] + j * b[i-1][j])%MOD;
}
}
}
int main()
{
int t;
fin >> t;
speta1();
speta2();
while(t--)
{
int x, N, M;
fin >> x >> N >> M;
if(x == 1)
{
fout << a[N][M] << '\n';
}
else if(x == 2)
{
fout << b[N][M] << '\n';
}
}
return 0;
}