Pagini recente » Cod sursa (job #545228) | Cod sursa (job #2524222) | Cod sursa (job #2708540) | Cod sursa (job #2762834) | Cod sursa (job #3210752)
#include <fstream>
#include <vector>
#define mod 98999
#define nmax 201
using namespace std;
ifstream cin("stirling.in");
ofstream cout("stirling.out");
pair<int,int> dp[nmax][nmax];
int n, m, q;
int main()
{
dp[0][0]={1,1};
for(int i=1; i<nmax; i++)
for(int j=1; j<nmax; j++)
{
dp[i][j].first=(dp[i-1][j-1].first%mod-(i-1)*dp[i-1][j].first%mod)%mod;
dp[i][j].second=(dp[i-1][j-1].second%mod+j*dp[i-1][j].second%mod)%mod;
}
int speta;
cin>>q;
while(q--)
{
cin>>speta>>n>>m;
if(speta==1)
cout<<dp[n][m].first%mod<<'\n';
if(speta==2)
cout<<dp[n][m].second%mod<<'\n';
}
return 0;
}