Cod sursa(job #3239605)

Utilizator Andrei-Dani-10Pisla Andrei Daniel Andrei-Dani-10 Data 6 august 2024 21:21:09
Problema Numerele lui Stirling Scor 0
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.64 kb
#include <fstream>
using namespace std;
ifstream in("stirling.in");
ofstream out("stirling.out");
int teste, speta, n, m;
int stirling[2][202][202];

int main(){
    in>>teste;

    stirling[0][1][1] = 1;
    stirling[1][1][1] = 1;

    for(int i = 2; i < n; i++){
        for(int j = 1; j <= i; j++){
            stirling[0][i][j] = (stirling[0][i - 1][j - 1] - (i - 1) * stirling[0][i - 1][j]) % 98999;
            stirling[1][i][j] = (stirling[1][i - 1][j - 1] + j * stirling[1][i - 1][j]) % 98999;
        }
    }

    for(int i = 1; i <= teste; i++)
        in>>speta>>n>>m, out<<stirling[speta - 1][n][m]<<"\n";
    return 0;
}