Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstdio>
- using namespace std;
- pair<int,int> a[20][20];
- int k,n;
- int main()
- {
- int i,j;
- cin>>n>>k;
- if(n==1)
- {
- cout<<k<<endl;
- return 0;
- }
- for(i=2;i<=k;i++)
- a[1][i].first=i-1;
- for(i=2;i<=n;i++)
- for(j=2;j<=k;j++)
- {
- a[i][j].second=a[i-1][j].first;
- a[i][j].first=(a[i-1][j].first+a[i-1][j].second)*(j-1);
- }
- cout<<a[n][k].first+a[n][k].second<<endl;
- return 0;
- }
Add Comment
Please, Sign In to add comment