Colored balls
Limits: 2 sec., 256 MiB
This statement was translated automatically from Ukrainian.
Marichka loves collecting colored balls. Currently, her collection contains \(a\) yellow balls and \(b\) green balls.
Zenyk loves playing with Marichka’s balls. One of his favorite activities is arranging the balls in a row, which turns out long, colorful, and beautiful.
Right now Zenyk wants to surprise Marichka and has set a goal to arrange the balls in a row such that the number of adjacent balls of different colors is as large as possible. Help him with this, find such an arrangement.
Input
The single line contains two integers \(a\) and \(b\) — the numbers of yellow and green balls in Marichka’s collection.
Output
In a single line, print a string consisting of \(a\) characters Y (representing
yellow balls) and \(b\) characters
G (representing green balls).
This string must contain the maximum number of pairs of adjacent balls of different colors.
If there are multiple answers that maximize this number, you are allowed to output any of them.
Constraints
\(0 \le a, b \le 1000\),
\(0 < a+b\).
Samples
| Input (stdin) | Output (stdout) |
|---|---|
| 1 2 | GYG |
| Input (stdin) | Output (stdout) |
|---|---|
| 4 0 | YYYY |
Notes
In the first example, there are two green balls and one yellow. The maximum number of adjacent pairs of balls of different colors is two.
In the second example, there are no green balls in the collection, so there can be no pairs of adjacent balls of different colors.
Submit a solution
| Element Type | Created | Who | Problem | Compiler | Result | Time (sec.) | Memory (MiB) | # | Actions |
|---|
| Element Type | Created | Who | Problem | Compiler | Result | Time (sec.) | Memory (MiB) | # | Actions |
|---|