Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- typedef long long ll;
- int main() {
- int n;
- cin >> n;
- int pow = 1;
- vector<int> tino, nino;
- nino.push_back(n);
- while(n > 0) {
- int ost = n % 3;
- if(ost == 0) {
- n /= 3;
- }
- else if(ost == 1) {
- n -= 1;
- n /= 3;
- tino.push_back(pow);
- }
- else {
- n += 1;
- n /= 3;
- nino.push_back(pow);
- }
- pow *= 3;
- }
- sort(tino.begin(), tino.end());
- sort(nino.begin(), nino.end());
- for(int x : nino) {
- cout << x << " ";
- }
- for(int x : tino) {
- cout << x << " ";
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement