Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2017
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <cstdio>
  3.  
  4. using namespace std;
  5.  
  6. int a[37][50]={0};
  7. int n,k;
  8.  
  9. int rec(int i, int t) {
  10. if (i==0) {
  11. if (t==k) return 1;
  12. else return 0;
  13. }
  14. if (t+i<=k) {
  15. if (a[i][t]==0) {
  16. a[i][t]+=rec(i-1,t+1);
  17. a[i][t]+=rec(i+1,t+1);
  18. }
  19. }
  20. return a[i][t];
  21. }
  22. int main()
  23. {
  24. scanf("%d%d", &n, &k);
  25. printf("%d", rec(n,0) );
  26. return 0;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement