abubaca

"Золотой" песок

Nov 23rd, 2018
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.35 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. long long temp[101] = { 0 };
  6.  
  7. long long rec(int n)
  8. {
  9.     if (n >= 0)
  10.     {
  11.         if (temp[n] == 0)
  12.             if (n > 0)
  13.             {
  14.                 temp[n] = rec(n - 50) + rec(n - 10) + rec(n - 5) + rec(n - 1);
  15.             }
  16.             else
  17.                 temp[n] = 1;
  18.         return temp[n];
  19.     }
  20.     return 0;
  21. }
  22.  
  23. int main()
  24. {
  25.     int n;
  26.     cin >> n;
  27.     cout << rec(n);
  28. }
Advertisement
Add Comment
Please, Sign In to add comment