Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- void solve(const std::pair<uint32_t, uint32_t>& left, const std::pair<uint32_t, uint32_t>& right, const uint32_t& max, uint32_t count = 2) {
- if (count >= max)
- return;
- std::pair<uint32_t, uint32_t> result = { left.first + right.first, left.second + right.second };
- solve(left, result, max, count + 1);
- std::cout << result.first << "/" << result.second << " ";
- solve(result, right, max, count + 1);
- }
- int main()
- {
- uint32_t n;
- std::cin >> n;
- uint32_t max = 2;
- for (uint32_t i = 2; i <= n; i++)
- max += 2 * i - 1;
- solve({ 0,1 }, { 1,0 }, max);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement