Advertisement
Mirbek

ИГРАЛЬНЫЕ КОСТИ (рекурсивный метод)

Feb 22nd, 2022
697
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.40 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. const int N = 1e6 + 5;
  6.  
  7. int n;
  8.  
  9. int rec(int x) {
  10.     if (x == n) return 1;
  11.     if (x > n) return 0;
  12.  
  13.     int ans = 0;
  14.     ans += rec(x + 1);
  15.     ans += rec(x + 2);
  16.     ans += rec(x + 3);
  17.     ans += rec(x + 4);
  18.     ans += rec(x + 5);
  19.     ans += rec(x + 6);
  20.  
  21.     return ans;
  22. }
  23.  
  24. int main(){
  25.     cin >> n;
  26.  
  27.     cout << rec(0) << endl;
  28. }
  29.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement