Contents

  • 类似三进制的意思
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;//3次一个周期
n /= 3;//右边的那个变三次左边的就加1(变一次),所以看有多少个三次
}
int i;
for(i = 0; i <= m - 2; i++)
printf("%c", color[res[i]]);
printf("%c\n", color[res[i]]);//最后一个单独处理
}
return 0;
}
Contents