Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- ifstream fin("stirling.in");
- ofstream fout("stirling.out");
- const short NMAX=205;
- const int MODULO=98999;
- int query,dp[NMAX][NMAX],DP[NMAX][NMAX];
- int main()
- {
- int t,n,k;
- fin>>query;
- ///Recurenta:S(n,k)=-(n-1)*S(n-1,k)+S(n-1,k-1)(De speta I)
- ///Recurenta:S(n,k)=S(n-1,k-1)+j*S(i-1,j)(De speta a II-a)
- dp[1][1]=DP[1][1]=1;
- for(int i=1;i<=NMAX-5;i++)
- for(int j=1;j<=NMAX-5;j++)
- if(i!=1 || j!=1)
- {
- dp[i][j]=(dp[i-1][j-1]-(1LL*(i-1)*dp[i-1][j])%MODULO)%MODULO;
- DP[i][j]=(DP[i-1][j-1]+(1LL*j*DP[i-1][j])%MODULO)%MODULO;
- }
- while(query--)
- {
- fin>>t>>n>>k;
- if(t==1)
- fout<<dp[n][k]<<"\n";
- else fout<<DP[n][k]<<"\n";
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment