Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <cstdio>
- using namespace std;
- int a[37][50]={0};
- int n,k;
- int rec(int i, int t) {
- if (i==0) {
- if (t==k) return 1;
- else return 0;
- }
- if (t+i<=k) {
- if (a[i][t]==0) {
- a[i][t]+=rec(i-1,t+1);
- a[i][t]+=rec(i+1,t+1);
- }
- }
- return a[i][t];
- }
- int main()
- {
- scanf("%d%d", &n, &k);
- printf("%d", rec(n,0) );
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement