Cod sursa(job #2371522)

Utilizator liviu2000Dragomirescu Liviu liviu2000 Data 6 martie 2019 18:03:44
Problema Numerele lui Stirling Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.86 kb
#include <bits/stdc++.h>
#define MOD 98999
#define N 205

using namespace std;

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

int st1[N][N] , st2[N][N] ;

void speta2()
{
    int i , j ;
    st2[1][1] = 1 ;
    for ( i = 2 ; i <= 200 ; i++ )
        for ( j = 1 ; j <= i ; j++ )
            st2[i][j] = (st2[i-1][j-1] + j*st2[i-1][j])%MOD ;
}

void speta1()
{
    int i , j ;
    st1[1][1] = 1 ;
    for ( i = 2 ; i <= 200 ; i++ )
        for ( j = 1 ; j <= i ; j++ )
            st1[i][j] = (st1[i-1][j-1] - (i-1)*st1[i-1][j])%MOD ;
}

int main()
{
    int t , ii , x , tp , y ;
    speta2();
    speta1() ;
    fin >> t ;
    for ( ii = 1 ; ii <= t ; ii++ )
    {
        fin >> tp >> x >> y ;
        if ( tp == 1 )
            fout << st1[x][y] << '\n' ;
        else
            fout << st2[x][y] << '\n' ;
    }
}