hdoj 【BestCoder Round #81 (div.2)】 5670 Machine
来源:互联网 发布:创业项目 知乎 编辑:程序博客网 时间:2024/06/05 00:37
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
给出一排彩色的灯,并且他们都连在同一个开关上。这些彩灯有R红,G绿,B蓝三种颜色,当按下开关时,最右边若是红灯,则变为绿灯,如果是绿灯则变为蓝灯,如果是蓝灯将再次变为红灯且它左边相邻的灯也会按照此顺序发生改变。即右边的灯变三次,左边的灯变一次.
代码如下:
#include<cstdio>#include<cstring>#include<algorithm>using namespace std;char str[33];char st[3]={'R','G','B'};int main(){int t ;scanf("%d",&t);while(t--){int m;__int64 n;int i;scanf("%d%I64d",&m,&n);for(i=0;i<33;i++)str[i]='R'; for(i=m-1;i>=0;i--) { str[i]=st[n%3]; n/=3;}for(i=0;i<m;i++){printf("%c",str[i]);}printf("\n");}}
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
0 0
- hdoj 【BestCoder Round #81 (div.2)】 5670 Machine
- hdoj BestCoder Round #81 (div.2) AA Machine
- BestCoder Round #81 (div.2) Machine
- BestCoder Round #81 (div.2):1001 Machine
- HDU 5670 Machine——BestCoder Round #81(div.2)
- BestCoder Round #81 (div.2) 1001 Machine(找规律)
- BestCoder Round #81 (div.2)-Machine(模拟)
- BestCoder Round #81 (div.2)
- BestCoder Round #81 (div.2)
- BestCoder Round #52 (div.2) 1001 Victor and Machine
- BestCoder Round #52 (div.2) Victor and Machine
- Victor and Machine----(BestCoder Round #52 (div.2))
- BestCoder Round #52 (div.2)HDU5417 Victor and Machine
- [hdu 5670][BestCoder Round #81 t1] Machine
- BestCoder Round #54 (div.2) HDOJ 5429 Geometric Progression(模拟)
- BestCoder Round #74 (div.2) T2 DFS HDOJ 5636
- BestCoder Round #74 (div.2) T3 Transform HDOJ 5637
- BestCoder Round #74 (div.2) T4 Toposort HDOJ 5638
- javaIO
- iOS逆向工程——获取app素材图片
- SSH连接时出现Host key verification failed的原因及解决方法
- Android学习精要-CheckedTextView控件
- IHS配置安全漏洞: 支持不推荐使用的 SSL 版本、在降级的旧加密上填充 Oracle、检测到 RC4 密码套件、支持弱 SSL 密码套件、 重构 RSA 导出键(又称为 FREAK)
- hdoj 【BestCoder Round #81 (div.2)】 5670 Machine
- js 学习网站
- AD10 PCB文件统一设置字体大小(默认字体大小)
- 字符串匹配算法总结
- SQL计算某一值连续出现的最大次数
- iOS 学习路线图
- VIN驱动个人总结
- java_io_文件夹中文件遍历
- Catalan数 卡特兰数