Cod sursa(job #3317264)

Utilizator octavurlurleteanu alexandru octavian octavurl Data 22 octombrie 2025 22:34:24
Problema Numerele lui Stirling Scor 100
Compilator cpp-64 Status done
Runda cex_02 Marime 2.83 kb
/*
          _____                            _____                           _______
         /\    \                          /\    \                         /::\    \
        /::\____\                        /::\    \                       /::::\    \
       /:::/    /                       /::::\    \                     /::::::\    \
      /:::/    /                       /::::::\    \                   /::::::::\    \
     /:::/    /                       /:::/\:::\    \                 /:::/~~\:::\    \
    /:::/    /                       /:::/__\:::\    \               /:::/    \:::\    \
   /:::/    /                       /::::\   \:::\    \             /:::/    / \:::\    \
  /:::/    /      _____            /::::::\   \:::\    \           /:::/____/   \:::\____\
 /:::/____/      /\    \          /:::/\:::\   \:::\    \         :::    |     |:::|    |
|:::|    /      /::\____\        /:::/  \:::\   \:::\____\        |:::|____|     |:::|    |
|:::|____\     /:::/    /        \::/    \:::\  /:::/    /         \:::\    \   /:::/    /
 \:::\    \   /:::/    /          \/____/ \:::\/:::/    /           \:::\    \ /:::/    /
  \:::\    \ /:::/    /                    \::::::/    /             \:::\    /:::/    /
   \:::\    /:::/    /                      \::::/    /               \:::\__/:::/    /
    \:::\__/:::/    /                       /:::/    /                 \::::::::/    /
     \::::::::/    /                       /:::/    /                   \::::::/    /
      \::::::/    /                       /:::/    /                     \::::/    /
       \::::/    /                       /:::/    /                       \::/____/
        \::/____/                        \::/    /                         ~~
         ~~                               \/____/

*/
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define ins(x) insert(x)
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define fast_ios ios_base::sync_with_stdio(0),cin.tie(nullptr),cout.tie(nullptr);
#define all(v) (v).begin() , (v).end()

using namespace std;

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

ll nxt()
{
ll x;
fin >> x ;
return x;
}
void close_files()
{
fin.close();
fout.close();
}
const int mod = 98999;
ll s[205][205];
ll S[205][205];

signed main()
{
    fast_ios
    ll p;
    fin >> p ;
    s[1][1]=S[1][1]=1;
    for ( ll i = 2 ; i <= 200 ; ++ i )
        for ( ll j = 1 ; j <= i ; ++ j )
        {
        S[i][j] = (S[i-1][j-1] + 1LL*j*S[i-1][j]) %mod;
        s[i][j] = (s[i-1][j-1] - 1LL*( i - 1 ) * s[i-1][j]) %mod;
        }

    while ( p -- )
    {
    ll x , n , m ;
    fin >> x >> n >> m;
    if ( x == 1 )
        fout << s[n][m] << '\n';
    else
        fout << S[n][m] << '\n';

    }

    close_files();
    return 0;
}