Machine

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 290    Accepted Submission(s):
179

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
pushed n(1≤n<2^63) times?
 
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 integers m(2≤m≤30) and n(1≤n<263) .
 
Output
For each test case, output the colour of m bulbs from
left to right.
R indicates red. G indicates green. B indicates blue.
 
Sample Input
3 1
2 3
 
Sample Output
RRG
GR
 
Recommend
wange2014
 
题目大意:初始状态下所有的灯都是红色的,输出经过n次变换后的灯。 
思路:就是把这个数转为3进制数,0,1,2分别为红,绿,蓝。。。
#include <iostream>
#include <cstdio>
using namespace std;
int main()
{
int j=, i, T, m, a[];
__int64 n;
cin>>T;
while(T--)
{
j=;
scanf("%d%I64d", &m, &n);
while(n!=)
{
a[++j]=n%;
n=n/;
}
while(m>j)
{
cout<<"R";
m--;
}
for(i=m;i>=;i--)
if(a[i]==)
printf("R");
else if(a[i]==)
printf("G");
else
printf("B");
printf("\n");
}
return ;
}

HDU 5670 Machine的更多相关文章

  1. HDU 5670 Machine 水题

    Machine 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5670 Description There is a machine with m(2 ...

  2. hdu 3842 Machine Works(cdq分治维护凸壳)

    题目链接:hdu 3842 Machine Works 详细题解: HDU 3842 Machine Works cdq分治 斜率优化 细节比较多,好好体会一下. 在维护斜率的时候要考虑x1与x2是否 ...

  3. 匈牙利算法模板 hdu 1150 Machine Schedule(二分匹配)

    二分图:https://blog.csdn.net/c20180630/article/details/70175814 https://blog.csdn.net/flynn_curry/artic ...

  4. hdu 1150 Machine Schedule 最少点覆盖转化为最大匹配

    Machine Schedule Time Limit: 1 Sec  Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php? ...

  5. hdu 1150 Machine Schedule 最少点覆盖

    Machine Schedule Time Limit: 1 Sec  Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php? ...

  6. hdu 1150 Machine Schedule(二分匹配,简单匈牙利算法)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1150 Machine Schedule Time Limit: 2000/1000 MS (Java/ ...

  7. HDU 4045 Machine scheduling (组合数学-斯特林数,组合数学-排列组合)

    Machine scheduling Time Limit: 5000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Other ...

  8. HDU 1150 Machine Schedule (二分图最小点覆盖)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1150 有两个机器a和b,分别有n个模式和m个模式.下面有k个任务,每个任务需要a的一个模式或者b的一个 ...

  9. POJ 1325、ZOJ 1364、HDU 1150 Machine Schedule - from lanshui_Yang

    Problem Description As we all know, machine scheduling is a very classical problem in computer scien ...

随机推荐

  1. $.toJSON的使用方法

    我们都会使用jQuery的ajax方法取得json数据但是我们有的时候也要使用json数据给PHP传值,这个怎么做哪? 首先去http://code.google.com/p/jquery-json/ ...

  2. js 获取select 中option 的个数

    //document.writeln(document.getElementById("sel").options.length); //document.writeln(docu ...

  3. 夺命雷公狗---DEDECMS----9dedecms单标签

    我们这一节课开始将dedecms的标签了,dedecms里面的标签分好多个的,我们先来看下他的标签长得啥样的先: 随便点击一个修改即可见到标签了: 这里面上面的大文本框里面有标签的用法下面有参数的说明 ...

  4. AMD机制与cMD的区别和概念简要介绍

    1.http://www.cnblogs.com/dojo-lzz/p/4707725.html 2.http://blog.chinaunix.net/uid-26672038-id-4112229 ...

  5. Mac下好用的取色器 Sip

    总有很多东西,你只是望一眼就已经神魂颠倒.措施有这样的App做的真的是用心的很,养眼,触发你内心冲动的美感.先留下一个,备忘. 太精致了 操作简单,左上角的有心圆点击就可以在任何地方取色了,取色点会z ...

  6. 将helps.php或者functions.php直接进行了加载

    TP3系列中functions.php文件默认其实是空文件,很好找.我们可以直接封装代码. Laravel5系列中的path/vendor/laravel/framework/src/Illumina ...

  7. 分布式拒绝服务攻击(DDoS)原理及防范

    DDoS攻击概念 DoS的攻击方式有很多种,最基本的DoS攻击就是利用合理的服务请求来占用过多的服务资源,从而使合法用户无法得到服务的响应. DDoS攻击手段是在传统的DoS攻击基础之上产生的一类攻击 ...

  8. 【转】MYSQL入门学习之二:使用正则表达式搜索

    转载地址:http://www.2cto.com/database/201212/173869.html 一.正则表达式介绍   www.2cto.com   正则表达式是用来匹配文本的特殊的串(字符 ...

  9. SIM卡应用-OPN,PLMN,SPN

    SIM卡应用 移动运营商已经将SIM卡用於很多不同的应用,下面列出了其中最主要的应 用∶ ·漫游应用∶确保手机可以在漫游之後选择缺省的运营商网络.一个SIM应用是可以在手机漫游到某个合作夥伴运营商网络 ...

  10. 编写一个函数func(),将此函数的输入参数(int型)逆序输出显示,如54321 –> 12345,要求使用递归,并且函数体代码不超过8行

    public class Test{ //中间变量 private String res = "0"; //方法 public int func(int i){ if(i>0 ...