Cod sursa(job #2071913)

Utilizator killer301Ioan Andrei Nicolae killer301 Data 21 noiembrie 2017 10:08:56
Problema Numerele lui Stirling Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.59 kb
#include <cstdio>

using namespace std;

const int NMAX = 200;
const int MOD = 98999;

int s[NMAX+5][NMAX+5];
int S[NMAX+5][NMAX+5];

int main()
{
	freopen("stirling.in", "r", stdin);
	freopen("stirling.out", "w", stdout);
	s[1][1] = 1;
	S[1][1] = 1;
	for(int i=2; i<=200; i++)
		for(int j=1; j<=i; j++)
		{
			s[i][j] = (s[i-1][j-1] - (i-1)*s[i-1][j])%MOD;
			S[i][j] = (S[i-1][j-1] + j*S[i-1][j])%MOD;
		}
	int Q;
	scanf("%d", &Q);
	while(Q--)
	{
		int type, x, y;
		scanf("%d%d%d", &type, &x, &y);
		printf("%d\n", type == 1 ? s[x][y] : S[x][y]);
	}
    return 0;
}