Pagini recente » Cod sursa (job #2705021) | Cod sursa (job #2175062) | Cod sursa (job #588925) | Cod sursa (job #3158257) | Cod sursa (job #3267835)
// https://www.infoarena.ro/problema/stirling - didactic
#include <stdio.h>
#define MAXN 200
typedef long long ll;
ll stirling[2][MAXN + 1][MAXN + 1];
int t;
int main() {
for (int i = 1; i <= MAXN; i++) {
stirling[0][i][i] = 1;
stirling[1][i][i] = 1;
for (int j = 1; j < i; j++) {
stirling[0][i][j] =
stirling[0][i - 1][j - 1] - (i - 1) * stirling[0][i - 1][j];
stirling[1][i][j] = stirling[1][i - 1][j - 1] + j * stirling[1][i - 1][j];
}
}
freopen("stirling.in", "r", stdin);
freopen("stirling.out", "w", stdout);
scanf("%d", &t);
for (int i = 0; i < t; i++) {
int c, n, m;
scanf("%d%d%d", &c, &n, &m);
printf("%lld\n", stirling[c-1][n][m]);
}
return 0;
}