Algorithm
The Easter Rabbit laid n eggs in a circle and is about to paint them.
Each egg should be painted one color out of 7: red, orange, yellow, green, blue, indigo or violet. Also, the following conditions should be satisfied:
- Each of the seven colors should be used to paint at least one egg.
- Any four eggs lying sequentially should be painted different colors.
Help the Easter Rabbit paint the eggs in the required manner. We know that it is always possible.
The only line contains an integer n — the amount of eggs (7 ≤ n ≤ 100).
Print one line consisting of n characters. The i-th character should describe the color of the i-th egg in the order they lie in the circle. The colors should be represented as follows: "R" stands for red, "O" stands for orange, "Y" stands for yellow, "G" stands for green, "B" stands for blue, "I" stands for indigo, "V" stands for violet.
If there are several answers, print any of them.
8
ROYGRBIV
13
ROYGBIVGBIVYG
The way the eggs will be painted in the first sample is shown on the picture:
Code Examples
#1 Code Example with C++ Programming
Code -
C++ Programming
#include <cstdio>
int main(){
const char array[7] = {'R','O','Y','G','B','I','V'};
int n(0); scanf("%d", &n);
for(int k = 0; k < 3; k++){printf("%c", array[k]);}
for(int k = 3; k < n; k++){printf("%c", array[3 + k%4]);}
puts("");
return 0;
}
Copy The Code &
Try With Live Editor
Input
Output
Demonstration
Codeforces Solution-B. Easter Eggs-Solution in C, C++, Java, Python