Advertisement
Guest User

Untitled

a guest
Feb 21st, 2020
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. #include <iostream>
  2. #include <algorithm>
  3. #include <vector>
  4. #include <map>
  5.  
  6. using namespace std;
  7. using ll = long long;
  8. map<ll, unsigned int> counted_values;
  9.  
  10. void get_value_in_map(ll i) {
  11. ll tmp_1;
  12. ll tmp_2;
  13. if (i <= 2) {
  14. counted_values[i] = 1;
  15. return;
  16. }
  17.  
  18. if (counted_values.count(i))
  19. return;
  20.  
  21. if (i % 2 == 1) {
  22. get_value_in_map(6 * i / 7);
  23. get_value_in_map(2 * i / 3);
  24.  
  25. counted_values[i] = counted_values[6 * i / 7] + counted_values[2 * i / 3];
  26. } else {
  27. get_value_in_map(i - 1);
  28. get_value_in_map(i - 3);
  29.  
  30. counted_values[i] = counted_values[i - 1] + counted_values[i - 3];
  31. }
  32. }
  33.  
  34. int main() {
  35. ll N;
  36. cin >> N;
  37. get_value_in_map(N);
  38.  
  39. cout << counted_values[N];
  40. return 0;
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement