#include using namespace std; using namespace chrono; #if __has_include() #include using namespace atcoder; #endif pair> ext_gcd(int64_t x, int64_t y) { if (y == 0) { return {x, {1, 0}}; } auto [g, p] = ext_gcd(y, x % y); auto [u, v] = p; // g == u * y + v * (x % y) // == u * y + v * (x - x / y * y) // == u * y + v * x - x / y * y * v // == v * x + (u - x / y * v) * y int64_t nu = v, nv = u - x / y * v; return {g, {nu, nv}}; } int main() { int64_t x, y, z; cin >> x >> y >> z; auto Cww = [&](string s) -> int64_t { if (10000 < s.size()) { cout << "ERROR too long" << endl; exit(0); } stack st; for (auto &&c : s) { if (c == 'c') { st.push(x); } else if (c == 'w') { st.push(y); } else if (c == 'C') { if (st.size() < 2) { cout << "ERROR in " << c << endl; exit(0); } auto a = st.top(); st.pop(); auto b = st.top(); st.pop(); st.push(a + b); } else if (c == 'W') { if (st.size() < 2) { cout << "ERROR in " << c << endl; exit(0); } auto a = st.top(); st.pop(); auto b = st.top(); st.pop(); st.push(a - b); } } if (st.empty()) { cout << "ERROR stack is empty" << endl; exit(0); } return st.top(); }; auto [g, p] = ext_gcd(x, y); auto [u, v] = p; u *= z / g; v *= z / g; if (g == 0) { if (z == 0) { cout << "ccW" << endl; return 0; } cout << "NO" << endl; return 0; } if (z % g != 0) { cout << "NO" << endl; return 0; } string ans = ""; if (0 <= u) { for (int64_t i = 0; i < u; i++) { ans += 'c'; } for (int64_t i = 0; i < u - 1; i++) { ans += 'C'; } } else { for (int64_t i = 0; i < -u + 2; i++) { ans += 'c'; } for (int64_t i = 0; i < -u + 1; i++) { ans += 'W'; } } if (0 <= v) { for (int64_t i = 0; i < v; i++) { ans += 'w'; } for (int64_t i = 0; i < v - 1; i++) { ans += 'C'; } } else { for (int64_t i = 0; i < -v + 2; i++) { ans += 'w'; } for (int64_t i = 0; i < -v + 1; i++) { ans += 'W'; } } if (u != 0 && v != 0) { ans += 'C'; } if (10000 < ans.size()) { cout << "NO" << endl; return 0; } cout << ans << endl; cerr << Cww(ans) << endl; return 0; }