Cod sursa(job #2281949)

Utilizator Vlad3108Tir Vlad Ioan Vlad3108 Data 12 noiembrie 2018 23:23:15
Problema Numerele lui Stirling Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.57 kb
#include <bits/stdc++.h>
using namespace std;
int S[3][201][201];
#define MOD 98999
int main(){
    freopen("stirling.in","r",stdin);
    freopen("stirling.out","w",stdout);
    S[1][1][1]=S[2][1][1]=1;
    for(int i=2;i<=200;++i)
        for(int j=1;j<=i;++j){
            S[1][i][j]=(1LL*S[1][i-1][j-1]-1LL*(i-1)*S[1][i-1][j])%MOD;
            S[2][i][j]=(1LL*S[2][i-1][j-1]+1LL*j*S[2][i-1][j])%MOD;
        }
    int n;
    scanf("%d",&n);
    while(n--){
        int sp,i,j;
        scanf("%d %d %d",&sp,&i,&j);
        printf("%d\n",S[sp][i][j]);
    }
}