BestCoder Round #81 (div.1)A

水题。。。就是n的三进制后m位

 1 #include<cstdio>
 2 #include<cstring>
 3 #include<cstdlib>
 4 #include<iostream>
 5 #include<queue>
 6 #include<stack>
 7 #include<cmath>
 8 #include<algorithm>
 9 #include<malloc.h>
10 using namespace std;
11 #define clc(a,b) memset(a,b,sizeof(a))
12 #define inf 0x3f3f3f3f
13 const int N=10010;
14 #define LL long long
15 const double eps = 1e-5;
16 const double pi = acos(-1);
17 // inline int r(){
18 //     int x=0,f=1;char ch=getchar();
19 //     while(ch>'9'||ch<'0'){if(ch=='-') f=-1;ch=getchar();}
20 //     while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
21 //     return x*f;
22 // }
23 
24 int main(){
25     int T;
26     while(~scanf("%d",&T)){
27          while(T--){
28             int m;
29             LL n;
30             scanf("%d %I64d",&m,&n);
31             int a[40];
32             clc(a,0);
33             int k=m;
34             LL q=n;
35             while(1){
36                 a[k]=q%3;
37                 q=q/3;
38                 k--;
39                 if(q==0||k==0)
40                     break;
41             }
42             for(int i=1;i<=m;i++){
43                 if(a[i]==0) printf("R");
44                 else if(a[i]==1) printf("G");
45                 else printf("B");
46             }
47             printf("\n");
48          }
49     }
50     return 0;
51 }
View Code

 

posted @ 2016-04-22 22:13  yyblues  阅读(202)  评论(0编辑  收藏  举报