Cod sursa(job #1212896)
| Utilizator | Data | 26 iulie 2014 13:42:28 | |
|---|---|---|---|
| Problema | Numerele lui Stirling | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.62 kb |
#include <fstream>
#define DIM 210
#define MOD 98999
using namespace std;
ifstream fin("stirling.in");
ofstream fout("stirling.out");
int A[DIM][DIM];
int B[DIM][DIM];
int t, n, k, x, i, j;
int main () {
A[1][1] = 1;
B[1][1] = 1;
for (i=2;i<=200;i++)
for (j=1;j<=i;j++) {
A[i][j] = (A[i-1][j-1] - (i-1)*A[i-1][j]) % MOD;
B[i][j] = (B[i-1][j-1] + j*B[i-1][j]) % MOD;
}
fin>>t;
for (;t--;) {
fin>>x>>n>>k;
if (x == 1)
fout<<A[n][k]<<"\n";
else
fout<<B[n][k]<<"\n";
}
return 0;
}
