Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- typedef long long int ll;
- ll m,n,arr[100],dp[57][67];
- ll dgdp(ll pos,ll pre)
- {
- if(pos==n)
- {
- return 1;
- }
- if(dp[pos][pre]!=-1)
- return dp[pos][pre];
- ll ans=0;
- for(ll i=0;i<m;i++)
- {
- if(abs(arr[i]-pre)<=2 || pre==0)
- ans+=dgdp(pos+1,arr[i]);
- }
- return dp[pos][pre]=ans;
- }
- int main()
- {
- // freopen("input.txt","r",stdin);
- // freopen("output.txt","w",stdout);
- ll i,j,k, t,cas;
- cin>>t;
- for(cas=1;cas<=t;cas++)
- {
- cin>>m>>n;
- for(i=0;i<m;i++)
- {
- cin>>arr[i];
- }
- memset(dp,-1,sizeof(dp));
- cout<<"Case "<<cas<<": "<<dgdp(0,0)<<endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement