Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- #define ll long long
- #define MOD 10056
- ll dp[10002],comb[1005][1005];
- void combinationcalculation()
- {
- comb[1][0]=1;
- comb[1][1]=1;
- for(int i=2;i<=1001;i++)
- {
- comb[i][0]=1;
- for(int j=1;j<=i;j++)
- {
- comb[i][j]=comb[i-1][j-1]+comb[i-1][j];
- comb[i][j]%=MOD;
- }
- }
- }
- ll process(ll n)
- {
- if(dp[n]!=-1)
- return dp[n];
- int ans=0;
- for(int i=1;i<=n;i++)
- {
- ans+=((comb[n][i])*(process(n-i)));
- ans%=MOD;
- }
- dp[n]=ans;
- return dp[n];
- }
- int main()
- {
- // freopen("in.txt","r",stdin);
- // freopen("out.txt","w",stdout);
- combinationcalculation();
- ll n,i,j,k,cas,t;
- for(i=1;i<=1001;i++)
- dp[i]=-1;
- dp[0]=1;
- process(1001);
- cin>>t;
- for(cas=1;cas<=t;cas++)
- {
- cin>>n;
- cout<<"Case "<<cas<<": "<<dp[n]<<endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement