fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int x[101][101];
  5.  
  6. int f(int n) {
  7. for(int i = 0; i <= n; i++) {
  8. for(int j = 0; j <= n; j++) {
  9. x[i][j] = 0;
  10. }
  11. }
  12. x[0][0] = 1;
  13. int s = 0;
  14. for(int i = 0; i <= n; i++) {
  15. for(int j = 0; j <= n; j++) {
  16. s += x[i][j];
  17. if(i < n && j < n)
  18. x[i+1][j+1] += x[i][j];
  19. if(i < n && j > 0)
  20. x[i+1][j-1] += x[i][j];
  21. }
  22. }
  23. return s;
  24. }
  25.  
  26. int main() {
  27. // your code goes here
  28. for(int i = 1; i <= 25; i++) {
  29. cout << f(i) << endl;
  30. }
  31. return 0;
  32. }
Success #stdin #stdout 0s 15280KB
stdin
Standard input is empty
stdout
2
4
7
13
23
43
78
148
274
526
988
1912
3628
7060
13495
26365
50675
99295
191673
376429
729145
1434577
2786655
5490811
10691111