#ifndef hari64 #include // #pragma GCC target("avx2") // #pragma GCC optimize("O3") // #pragma GCC optimize("unroll-loops") #define debug(...) #else #include "util/viewer.hpp" #define debug(...) viewer::_debug(__LINE__, #__VA_ARGS__, __VA_ARGS__) #endif // clang-format off using namespace std; template using vc = vector; template using vvc = vector>; template using vvvc = vector>; using ll = long long; using ld = long double; using pii = pair; using pll = pair; using tiii = tuple; using tlll = tuple; using vi = vc; using vvi = vvc; using vvvi = vvvc; using vll = vc; using vvll = vvc; using vvvll = vvvc; using vb = vc; using vvb = vvc; using vvvb = vvvc; using vpii = vc; using vvpii = vvc; using vpll = vc; using vvpll = vvc; using vtiii = vc; using vvtiii = vvc; using vtlll = vc; using vvtlll = vvc; #define ALL(x) begin(x), end(x) #define RALL(x) (x).rbegin(), (x).rend() constexpr int INF = 1001001001; constexpr long long INFll = 1001001001001001001; template bool chmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; } template bool chmin(T& a, const T& b) { return a > b ? a = b, 1 : 0; } // clang-format on struct Xor128 { // period 2^128 - 1 uint32_t x, y, z, w; static constexpr uint32_t min() { return 0; } static constexpr uint32_t max() { return UINT32_MAX; } Xor128(uint32_t seed = 0) : x(123456789), y(362436069), z(521288629), w(88675123 + seed) {} uint32_t operator()() { uint32_t t = x ^ (x << 11); x = y; y = z; z = w; return w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)); } uint32_t operator()(uint32_t l, uint32_t r) { return ((*this)() % (r - l)) + l; } uint32_t operator()(uint32_t r) { return (*this)() % r; } }; struct Rand { // https://docs.python.org/ja/3/library/random.html Rand(){}; Rand(int seed) : gen(seed){}; // シードを変更します inline void set_seed(int seed) { Xor128 _gen(seed); gen = _gen; } // ランダムな浮動小数点数(範囲は[0.0, 1.0)) を返します inline double random() { return (double)gen() / (double)gen.max(); } // a <= b であれば a <= N <= b 、b < a であれば b <= N <= a // であるようなランダムな浮動小数点数 N を返します inline double uniform(double a, double b) { if (b < a) swap(a, b); return a + (b - a) * double(gen()) / double(gen.max()); } // range(0, stop) の要素からランダムに選ばれた要素を返します inline uint32_t randrange(uint32_t r) { return gen(r); } // range(start, stop) の要素からランダムに選ばれた要素を返します inline uint32_t randrange(uint32_t l, uint32_t r) { return gen(l, r); } // a <= N <= b であるようなランダムな整数 N を返します randrange(a, b + 1) // のエイリアスです inline uint32_t randint(uint32_t l, uint32_t r) { return gen(l, r + 1); } // シーケンス x をインプレースにシャッフルします template void shuffle(vector& x) { for (int i = x.size(), j; i > 1;) { j = gen(i); swap(x[j], x[--i]); } } // 空でないシーケンス seq からランダムに要素を返します template T choice(const vector& seq) { assert(!seq.empty()); return seq[gen(seq.size())]; } // 相対的な重みに基づいて要素が選ばれます (※複数回呼ぶ場合は処理を変えた方が良い) template T choice(const vector& seq, const vector& weights) { assert(seq.size() == weights.size()); vector acc(weights.size()); acc[0] = weights[0]; for (int i = 1; i < int(weights.size()); i++) acc[i] = acc[i - 1] + weights[i]; return seq[lower_bound(acc.begin(), acc.end(), random() * acc.back()) - acc.begin()]; } // 母集団のシーケンスまたは集合から選ばれた長さ k // の一意な要素からなるリストを返します 重複無しのランダムサンプリングに用いられます template vector sample(const vector& p, int k) { int j, i = 0, n = p.size(); assert(0 <= k && k <= n); vector ret(k); unordered_set s; for (; i < k; i++) { do { j = gen(n); } while (s.find(j) != s.end()); s.insert(j); ret[i] = p[j]; } return ret; } // 正規分布です mu は平均で sigma は標準偏差です double normalvariate(double mu = 0.0, double sigma = 1.0) { double u2, z, NV = 4 * exp(-0.5) / sqrt(2.0); while (true) { u2 = 1.0 - random(); z = NV * (random() - 0.5) / u2; if (z * z / 4.0 <= -log(u2)) break; } return mu + z * sigma; } private: Xor128 gen; } myrand; int main() { cin.tie(0); ios::sync_with_stdio(false); ll N; cin >> N; while (true) { set seen; vc path; vc ans; auto dfs = [&](const auto& f, ll x) -> void { debug(x); if (!ans.empty()) return; if (seen.count(x)) return; if (x == 1) { ans = path; return; } seen.insert(x); if (x % 2 == 0) { path.push_back('/'); f(f, x / 2); path.pop_back(); } else { if (x < (ll)1e18 / 3) { if (myrand.random() < 0.5) { path.push_back('+'); f(f, 3 * x + 1); path.pop_back(); path.push_back('-'); f(f, 3 * x - 1); path.pop_back(); } else { path.push_back('-'); f(f, 3 * x - 1); path.pop_back(); path.push_back('+'); f(f, 3 * x + 1); path.pop_back(); } } } }; dfs(dfs, N); if (int(path.size()) < 10000) { cout << ans.size() << endl; for (auto& elem : ans) cout << elem << ' '; cout << endl; return 0; } } return 0; }