#include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #ifndef INCLUDED_MAIN #define INCLUDED_MAIN #include __FILE__ using P = pair; i32 main() { i64 n; cin >> n; unordered_map memo; unordered_map pref; queue

q; q.emplace(n, 0); while (!q.empty()) { auto [x, d] = q.front(); q.pop(); if (memo.count(x)) continue; memo[x] = d; if (d + 1 > 10'000) continue; if (x == 1) break; if (x % 2 == 0) { if (memo.contains(x / 2)) continue; q.emplace(x / 2, d + 1); pref[x / 2] = '/'; } else { if (!memo.contains(3*x - 1)) { q.emplace(3*x - 1, d + 1); pref[3*x - 1] = '-'; } if (!memo.contains(3*x + 1)) { q.emplace(3*x + 1, d + 1); pref[3*x + 1] = '+'; } } } i64 now = 1; string ans; while (now != n) { ans += pref[now]; if (pref[now] == '/') { now *= 2; } else if (pref[now] == '-') { now = (now + 1) / 3; } else { now = (now - 1) / 3; } } ranges::reverse(ans); cout << memo[1] << "\n" << ans << endl; } /********************************************************************************/ #else #ifdef ONLINE_JUDGE #define debug(x) {} #else const int DEBUG_PRINT = 10; const string bold = "\e[1m"; const string cyan = "\e[36m"; const string red = "\e[31m"; const string reset = "\e[0m"; #define debug(x) {cerr << bold << cyan << "[" << red << __LINE__ << cyan << "] "<< #x << ": " << reset; debgp(x); } template void debgp(T &x) { cerr << x; } template void debgp(pair &p) { cerr << "("; debgp(p.first); cerr << ", "; debgp(p.second); cerr << ")"; } template void debgp(vector &v) { cerr << "["; for (int i=0; i DEBUG_PRINT) cerr << " … ]\n"; } template void debgp(vector> &v) {cerr<<"[\n"; for (int i=0; i DEBUG_PRINT) cerr<<" ︙\n"; ; cerr << "]\n"; } #endif using i32 = int; using i64 = long long; const i64 INF = 0x0f0f'0f0f'0f0f'0f0f; template bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; } template bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; } vector dx4 = {1, 0, -1, 0}; vector dy4 = {0, 1, 0, -1}; vector dx8 = {1, 1, 0, -1, -1, -1, 0, 1}; vector dy8 = {0, 1, 1, 1, 0, -1, -1, -1}; template istream& operator>>(istream&i,pair&v){ i>>v.first>>v.second; return i; } template istream& operator>>(istream&i,vector&v){ for(T&e : v) i>>e; return i; } template ostream& operator<<(ostream &o, pair &p){o<<"("< ostream& operator<<(ostream&o,vector&v){for(int i=0; i optional position(vector&v, T x) { auto it = std::find(v.begin(), v.end(), x); if (it == v.end()) return nullopt; return it - v.begin(); } optional position(string &v, char x) { auto it = std::find(v.begin(), v.end(), x); if (it == v.end()) return nullopt; return it - v.begin(); } template vector> run_length_encoding(vector&v) { vector> res; if (v.empty()) return res; res.emplace_back(v[0], 0); for (const auto& x : v) { if (res.back().first == x) { res.back().second++; } else { res.emplace_back(x, 1); } } return res; } struct init{init(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<