【BestCoder Round #81 (div.2)】HDU5670Machine
来源:互联网 发布:最好的建筑设计软件 编辑:程序博客网 时间:2024/04/30 01:19
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5670
Problem Description
There is a machine with m(2≤m≤30) coloured bulbs and a button.When the button is pushed, the rightmost bulb changes.
For any changed bulb,
if it is red now it will be green;
if it is green now it will be blue;
if it is blue now it will be red and the bulb that on the left(if it exists) will change too.
Initally all the bulbs are red. What colour are the bulbs after the button be
pushedn(1≤n<263) times?
For any changed bulb,
if it is red now it will be green;
if it is green now it will be blue;
if it is blue now it will be red and the bulb that on the left(if it exists) will change too.
Initally all the bulbs are red. What colour are the bulbs after the button be
pushed
Input
There are multiple test cases. The first line of input contains an integer T(1≤T≤15) indicating the number of test cases. For each test case:
The only line contains two integersm(2≤m≤30) and n(1≤n<263) .
The only line contains two integers
Output
For each test case, output the colour of m bulbs from left to right.
R indicates red. G indicates green. B indicates blue.
R indicates red. G indicates green. B indicates blue.
Sample Input
23 12 3
Sample Output
RRGGR
代码:
#include<iostream>using namespace std;int main(){ int t; long long m,n; long long a[30]; a[1]=3;a[0]=1; for(int i=1;i<30;i++){ a[i]=3*a[i-1]; } cin>>t; while(t--){ cin>>m>>n; for(int i=m;i>=1;i--){ switch((n/a[i-1])%3){ case 0: cout<<'R'; break; case 1: cout<<'G'; break; case 2: cout<<'B'; break; } } cout<<endl; } return 0;}
0 0
- 【BestCoder Round #81 (div.2)】HDU5670Machine
- BestCoder Round #81 (div.2)
- BestCoder Round #81 (div.2)
- BestCoder Round #81 (div.2) Machine
- BestCoder Round #81 (div.2):1001 Machine
- BestCoder Round #81 (div.2) CC String
- BestCoder Round #81 (div.2)A
- 【BestCoder Round #81 (div.2)】HDU5671Matrix
- BestCoder Round #11 (Div. 2)
- BestCoder Round #11 (Div. 2)
- BestCoder Round #50 (div.2)
- BestCoder Round #50 (div.2)
- BestCoder Round 50 (div 2)
- BestCoder Round #50 (div.2)
- #BestCoder Round #50 (div.2)
- BestCoder Round #50 (div.2)
- BestCoder Round #54 (div.2)
- BestCoder Round #56 (div.2)
- Linux驱动LCD driver学习总结
- linux命令大全(4)
- cmd命令中adb报错error: cannot parse version string: kg01
- JSON与fastjson
- JavaScript中this的理解
- 【BestCoder Round #81 (div.2)】HDU5670Machine
- (二)认识标签(1)
- 算法1.1.15/16/18/19题
- 《STL源码剖析》学习笔记-第5章 关联式容器(二)
- 上机题目(初级)-大数求和
- 聊聊Socket、TCP/IP、HTTP、FTP及网络编程
- Androidstuido快捷键
- 玩转Android之加速度传感器的使用,模仿微信摇一摇
- Linux安装Java