fork(1) download
  1. #include <iostream>
  2. #include <map>
  3.  
  4. using namespace std;
  5.  
  6. map <long long, unsigned int> mp;
  7.  
  8. unsigned int f(const long long n)
  9. {
  10. if (n <= 2)
  11. return 1;
  12.  
  13. if (mp[n])
  14. return mp[n];
  15.  
  16. if (n % 2)
  17. return mp[n] = f(6 * n / 7) + f(2 * n / 3);
  18.  
  19. return mp[n] = f(n - 1) + f(n - 3);
  20. }
  21.  
  22. int main()
  23. {
  24. long long n;
  25. cin >> n;
  26. cout << f(n) << endl;
  27. }
Success #stdin #stdout 0s 4320KB
stdin
Standard input is empty
stdout
1