Cod sursa(job #1533492)

Utilizator tudi98Cozma Tudor tudi98 Data 22 noiembrie 2015 16:56:20
Problema Numerele lui Stirling Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.83 kb
#include <fstream>
using namespace std;
#define Mod 98999

int s[201][201], S[201][201];

void Stirling_Speta_I(int n,int m)
{
    s[1][1] = 1;
    for (int i = 2; i <= n; i++)
        for (int j = 1; j <= i; j++)
            s[i][j] = (s[i-1][j-1] - (i-1)*s[i-1][j]) % Mod;
}

void Stirling_Speta_II(int n,int m)
{
    S[1][1] = 1;
    for (int i = 2; i <= n; i++)
        for (int j = 1; j <= i; j++)
            S[i][j] = (S[i-1][j-1] + j * S[i-1][j]) % Mod;
}

int main()
{
    ifstream fin("stirling.in");
    ofstream fout("stirling.out");

    Stirling_Speta_I(200,200);
    Stirling_Speta_II(200,200);

    int t;
    fin >> t;
    while (t--)
    {
        int a,b,c;
        fin >> a >> b >> c;
        if (a == 1)
            fout << s[b][c] << "\n";
        else fout << S[b][c] << "\n";
    }
}