1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
| #include<cmath> #include <cstdio> #include <cstring>
int main() { long long n = 0; int T, m; char color[] = {'R', 'G', 'B'}; int res[30];
scanf("%d", &T); while(T--){ scanf("%d%I64d", &m, &n); memset(res, 0, sizeof(res)); for(int i = m - 1; i >= 0; i--){ res[i] = n % 3; n /= 3; } int i; for(i = 0; i <= m - 2; i++) printf("%c", color[res[i]]); printf("%c\n", color[res[i]]); } return 0; }
|