Pagini recente » Cod sursa (job #2520841) | Cod sursa (job #2482734) | Cod sursa (job #1823137) | Cod sursa (job #2665113) | Cod sursa (job #2051347)
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ifstream f("stirling.in");
ofstream g("stirling.out");
const ll NMax = 203;
const ll mod = 98999;
ll stir1[NMax][NMax],stir2[NMax][NMax];
ll x,n,m,t;
int main()
{
f >> t;
stir1[1][1] = 1;
stir2[1][1] = 1;
for(ll i = 1; i <= NMax - 2; ++i){
for(ll j = 1; j <= NMax - 2; ++j){
if(i == 1 && j == 1)
continue;
stir1[i][j] = (stir1[i - 1][j - 1] - (i - 1) * stir1[i - 1][j]);
stir1[i][j] %= mod;
stir2[i][j] = stir2[i - 1][j - 1] + j * stir2[i - 1][j];
stir2[i][j] %= mod;
}
}
while(t--){
f >> x >> n >> m;
if(x == 1){
g << stir1[n][m] << '\n';
}else{
g << stir2[n][m] << '\n';
}
}
return 0;
}