Skip to content

Instantly share code, notes, and snippets.

@pewniak747
Created April 16, 2010 15:09
Show Gist options
  • Save pewniak747/368531 to your computer and use it in GitHub Desktop.
Save pewniak747/368531 to your computer and use it in GitHub Desktop.
#include <iostream>
#include <vector>
int main() {
int szala1, szala2 = 0;
long mnoznik = 1;
std::vector<int> s1, s2;
std::cin >> szala1;
while(szala1 != szala2) {
if((szala1%3+1)%3+1 == (szala2%3+1)%3) {
s1.push_back(mnoznik);
szala1++;
}
else if((szala1%3+1)%3 == (szala2%3+1)%3+1) {
s2.push_back(mnoznik);
szala2++;
}
szala1 /= 3;
szala2 /= 3;
mnoznik *= 3;
}
std::cout << s1.size();
for(int i=0; i<s1.size(); i++) std::cout << " " << s1[i];
std::cout << "\n" << s2.size();
for(int i=0; i<s2.size(); i++) std::cout << " " << s2[i];
std::cout << "\n";cd
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment