On
Christmas, in the evening, there were three flowers in the window, from left to
right: geranium, crocus and violet. Every morning Masha cleans the dust and
changes position of the right flower with central one. In the afternoon, Tanya
waters the flowers and swaps left and central flowers. Print the order of the
flowers after k days, at night.
Input. The first line contains a number
of test cases m (1 ≤ m ≤ 12). Each of the following m lines contains the number of days k (1 ≤ k ≤ 1000).
Output. Print for
each test case in a separate line three Latin letters ‘G’, ‘C’ and ‘V’ (capital
letters, no spaces), representing the order of flowers in k days (from left to right). Here G stands for geranium, C for
crocus and V for violet.
Sample input |
Sample output |
2 1 5 |
VGC CVG |
conditional statement
Algorithm
analysis
Initially
the flowers on the window have the order GCV (geranium,
crocus and violet). After the first day the order of
the flowers will be changed to VGC (violet, geranium and crocus). After the second day the flowers will be in the order CVG
(crocus, violet and geranium). At the
end of the third day the order of the flowers will be the same as it was at the
start of the first day. Then the sequence of flowers permutations will be
repeated. Thus the answer to the problem will be as follows:
·
If k is divisible by 3, the flowers will
be in the order GCV.
·
If the remainder of the
division of k by 3 equals to 1, the
flowers will be in the order VGC.
·
If the remainder of the
division of k by 3 equals to 2, the
flowers will be in the order CVG.
Read input
data and print the sequence of flowers depending on the remainder from division
of number of the days k by 3.
scanf("%d",&n);
while(n--)
{
scanf("%d",&a);
if (a % 3 ==
0) puts("GCV"); else
if (a % 3 ==
1) puts("VGC"); else puts("CVG");
}
import java.util.*;
public class Main
{
public static void main(String[] args)
{
Scanner con = new Scanner(System.in);
int n = con.nextInt();
while(n-- > 0)
{
int a = con.nextInt();
if (a % 3 == 0) System.out.println("GCV"); else
if (a % 3 == 1) System.out.println("VGC"); else
System.out.println("CVG");
}
con.close();
}
}