Cod sursa(job #1983113)

Utilizator andreiudilaUdila Andrei andreiudila Data 21 mai 2017 12:15:48
Problema Numerele lui Stirling Scor 10
Compilator cpp Status done
Runda Arhiva educationala Marime 0.66 kb
#include <fstream>
using namespace std;
ifstream cin("stirling.in");
ofstream cout("stirling.out");

long long t,n,m,x,y,a[205][205],b[205][205],i,j,c;
void stirling()
{
    a[0][0]=1;
    b[0][0]=1;
    for(int i=1;i<=200;++i)
        for(int j=1;j<=200;++j)
        {
            a[i][j]=(a[i-1][j-1])%98999 - ((i-1)*a[i-1][j])&98999;
            a[i][j]%=98999;
            b[i][j]=(b[i-1][j-1])%98999 + (j*b[i-1][j])%98999;
            b[i][j]%=98999;
        }

}
int main()
{
    stirling();
    cin>>t;
    while(t--)
    {
        cin>>c>>x>>y;
        if(c==1) cout<<a[x][y]<<"\n";
        else cout<<b[x][y]<<"\n";
    }
    return 0;
}