local mfl, mce = math.floor, math.ceil local mab = math.abs local function getgcd(x, y) while 0 < x do x, y = y % x, x end return y end local function bezout_eq(a, b, Z) if b == 0 then return Z, 0 end local y, x = bezout_eq(b, a % b, Z) y = y - mfl(a / b) * x return x, y end local function triplediv(xmin, xmax, func) local left_v, right_v = func(xmin), func(xmax) while 1000 < xmax - xmin do local xmid1, xmid2 = mfl((xmin * 2 + xmax) / 3), mfl((xmin + xmax * 2) / 3) local mid_v1, mid_v2 = func(xmid1), func(xmid2) if left_v > mid_v1 then if mid_v2 > right_v then xmin = xmid2 left_v = mid_v2 elseif mid_v1 > mid_v2 then xmin = xmid1 left_v = mid_v1 else xmax = xmid2 right_v = mid_v2 end else if mid_v2 < right_v then xmax = xmid1 right_v = mid_v1 elseif mid_v1 < mid_v2 then xmin = xmid1 left_v = mid_v1 else xmax = xmid2 right_v = mid_v2 end end end -- return (xmin + xmax) / 2 return xmin, xmax end local x, y, z = io.read("*n", "*n", "*n") if x == 0 and y == 0 then if z == 0 then print("c") else print("NO") end elseif x == 0 then if z == 0 then print("c") elseif z % y == 0 then local cnt = mfl(z / y) if cnt * 2 - 1 <= 10000 then io.write(string.rep("w", cnt)) io.write(string.rep("C", cnt - 1)) io.write("\n") else print("NO") end else print("NO") end elseif y == 0 then if z == 0 then print("w") elseif z % x == 0 then local cnt = mfl(z / x) if cnt * 2 - 1 <= 10000 then io.write(string.rep("c", cnt)) io.write(string.rep("C", cnt - 1)) io.write("\n") else print("NO") end else print("NO") end else local gcd = getgcd(x, y) if z % gcd ~= 0 then print("NO") os.exit() end x, y, z = mfl(x / gcd), mfl(y / gcd), mfl(z / gcd) local a1, b1 = bezout_eq(x, y, z) -- print(a1, b1) if 0 < a1 then local q = mce(a1 / y) qmin, qmax = triplediv(0, q, function(Q) return mab(a1 - y * Q) + mab(b1 + x * Q) end) local ca, cb, v = a1, b1, mab(a1) + mab(b1) for iq = qmin, qmax do local vv = mab(a1 - y * iq) + mab(b1 + x * iq) if vv < v then ca, cb, v = a1 - y * iq, b1 + x * iq, vv end end a1, b1 = ca, cb elseif 0 < b1 then local q = mce(b1 / x) qmin, qmax = triplediv(0, q, function(Q) return mab(a1 + y * Q) + mab(b1 - x * Q) end) local ca, cb, v = a1, b1, mab(a1) + mab(b1) for iq = qmin, qmax do local vv = mab(a1 + y * iq) + mab(b1 - x * iq) if vv < v then ca, cb, v = a1 + y * iq, b1 - x * iq, vv end end a1, b1 = ca, cb end -- print(a1, b1) z = 1 local cnt = (mab(a1) + mab(b1)) if cnt * 2 - 1 <= 10000 then if a1 == 0 then io.write(string.rep("w", b1)) io.write(string.rep("C", b1 - 1)) io.write("\n") elseif b1 == 0 then io.write(string.rep("c", a1)) io.write(string.rep("C", a1 - 1)) io.write("\n") elseif 0 <= a1 and 0 <= b1 then io.write(string.rep("c", a1)) io.write(string.rep("w", b1)) io.write(string.rep("C", b1 - 1)) io.write(string.rep("C", a1)) io.write("\n") elseif a1 <= 0 then io.write(string.rep("c", -a1)) io.write(string.rep("w", b1)) io.write(string.rep("C", b1 - 1)) io.write(string.rep("W", -a1)) io.write("\n") else io.write(string.rep("w", -b1)) io.write(string.rep("c", a1)) io.write(string.rep("C", a1 - 1)) io.write(string.rep("W", -b1)) io.write("\n") end else print("NO") end end