given a non-negative integer x, the decimal portrayal of which contains n digits. You need to shading every its digit in red or dark, so the number shaped by the red digits is separable by A, and the number framed by the dark digits is detachable by B.
computer science | c++ code | it's not graded. Correct answer will upvoted else downvoted.
It is given a non-negative integer x, the decimal portrayal of which contains n digits. You need to shading every its digit in red or dark, so the number shaped by the red digits is separable by A, and the number framed by the dark digits is detachable by B.
No less than one digit should be shaded in every one of two tones. Consider, the include of digits hued in red is r and the include of digits hued in dark is b. Among all potential colorings of the given number x, you need to output any to such an extent that the worth of |r−b| is the base conceivable.
Note that the number x and the numbers shaped by digits of each tone, may contain driving zeros.
Input :The principal line contains one integer t (1≤t≤10) — the number of experiments. Then, at that point, t experiments follow.
Each experiment comprises of two lines. The main line contains three integers n, A, B (2≤n≤40, 1≤A,B≤40). The subsequent line contains a non-negative integer x containing precisely n digits and likely containing driving zeroes.
Output :For each experiment, output in a different line: - 1 if the ideal shading doesn't exist; a string s of n characters, every one of them is a letter 'R' or 'B'. In the event that the I-th digit of the number x is shaded in red, then, at that point, the I-th character of the string s should be the letter 'R', in any case the letter 'B'.
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 1 images