/* * Problem link * http://yukicoder.me/problems/1100 */ #include using namespace std; struct INIT{INIT(){cin.tie(0);ios_base::sync_with_stdio(false);} }init; typedef long long LL; inline bool inner(LL x,LL lb,LL ub) { return(lb <= x && x <= ub); } #define SZ 100000 pair _used[SZ * 2 + 1]; /*小さいケースならBFSで最適解が求まる*/ int main() { #ifdef INPUT_FROM_FILE ifstream cin("sample.in"); ofstream cout("sample.out"); #endif LL x, y, z; cin >> x >> y >> z; assert(inner(x, 0, 100000000)); assert(inner(y, 0, 100000000)); assert(inner(z, 0, 100000000)); fill(_used, _used + SZ * 2 + 1, make_pair('-', '-')); pair *used = _used + SZ; queue que; used[x] = make_pair('c', '-'); used[y] = make_pair('w', '-'); que.push(x); que.push(y); while (que.empty() == false) { auto v = que.front();que.pop(); if (inner(v + x, -SZ, SZ) && used[v + x].first == '-') { used[v + x] = make_pair('c', 'C'); que.push(v + x); } if (inner(v - x, -SZ, SZ) && used[v - x].first == '-') { used[v - x] = make_pair('c', 'W'); que.push(v - x); } if (inner(v + y, -SZ, SZ) && used[v + y].first == '-') { used[v + y] = make_pair('w', 'C'); que.push(v + y); } if (inner(v - y, -SZ, SZ) && used[v - y].first == '-') { used[v - y] = make_pair('w', 'W'); que.push(v - y); } } if (inner(z, -SZ, SZ) == false || used[z].first == '-') { cout << "mourennaihasimasenn" << endl; return 0; } LL v = z; string p, q; while (true) { p += used[v].first; if (used[v].second == '-')break; q += used[v].second; if (used[v].first == 'c'&&used[v].second == 'C')v = v - x; else if (used[v].first == 'c'&&used[v].second == 'W')v = v + x; else if (used[v].first == 'w'&&used[v].second == 'C')v = v - y; else if (used[v].first == 'w'&&used[v].second == 'W')v = v + y; }; reverse(q.begin(), q.end()); cout << p + q << endl; return 0; }