Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <stack>
- #include <vector>
- using namespace std;
- void opp2(int L, int K);
- void opp05 (int L, int K);
- stack<int> num;
- int main()
- {
- int L, K;
- cin >> L >> K;
- L *= 2;
- vector<int> array (1);
- opp2(L, K);
- opp05(L, K);
- int counter = 0;
- int temp;
- int flag;
- array[0] = num.top();
- num.pop();
- while (!num.empty())
- {
- counter++;
- do
- {
- temp = num.top();
- num.pop();
- flag = 0;
- for (int j = 0; j < counter; j++)
- {
- if (temp == array[j])
- {
- flag = 1;
- break;
- }
- if (j == counter - 1)
- array[counter] = temp;
- }
- } while (flag == 1);
- }
- cout << counter + 1;
- return 0;
- }
- void opp2(int L, int K)
- {
- L /= 2;
- if (K == 1)
- num.push(L);
- else
- {
- if (L % 2 != 1)
- opp2(L, K - 1);
- opp05(L, K - 1);
- }
- }
- void opp05 (int L, int K)
- {
- L--;
- if (K == 1)
- num.push(L);
- else
- {
- if (L % 2 != 1)
- opp2(L, K - 1);
- opp05(L, K - 1);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement