Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <algorithm>
- #include <vector>
- #include <map>
- using namespace std;
- using ll = long long;
- map<ll, unsigned int> counted_values;
- void get_value_in_map(ll i) {
- ll tmp_1;
- ll tmp_2;
- if (i <= 2) {
- counted_values[i] = 1;
- return;
- }
- if (counted_values.count(i))
- return;
- if (i % 2 == 1) {
- get_value_in_map(6 * i / 7);
- get_value_in_map(2 * i / 3);
- counted_values[i] = counted_values[6 * i / 7] + counted_values[2 * i / 3];
- } else {
- get_value_in_map(i - 1);
- get_value_in_map(i - 3);
- counted_values[i] = counted_values[i - 1] + counted_values[i - 3];
- }
- }
- int main() {
- ll N;
- cin >> N;
- get_value_in_map(N);
- cout << counted_values[N];
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement