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. 【py技巧】使用reload重导入修改过的包或模块

    #使用import导入 import my_module my_module.something() #out - orignal #这里修改输出 - changed reload(my_module ...

  2. 关于陈冰、陈良乔以及《我的第一本C++书》【转】

    出处:如何在淘宝上卖出 600 本自己写的 C++ 入门书? 陈冰:<我的第一本C++书> 策划编辑,现为图灵公司副总编,<C程序设计伴侣>策划编辑 陈良乔:<我的第一本 ...

  3. 菜鸟,大牛和教主三者的区别(转自hzwer)

    菜鸟,大牛和教主,三者的区别 对菜鸟来说题目有三种:会算法且能AC的,会算法但不能AC的,不会做的 对大牛来说题目有两种:会做的,不会做的 对教主来说题目有两种:能AC的,数据有错的 菜鸟提交WA了, ...

  4. scala的静态,单列模式

    package com.test.scala.test /** * 单例对象,这种对象不能提供构造函数 */ object SingleObject { private var lastnumber= ...

  5. TreeNode动态邦定事件

    1. 显示不能用TextField,应该用StaticText 2. public void SetNodesAction(Tree t, String methodbind){ ArrayList ...

  6. top.location.href和localtion.href有什么不同

    top.location.href=”url”          在顶层页面打开url(跳出框架) self.location.href=”url”         仅在本页面打开url地址 pare ...

  7. Java中类方法与实例方法的区别

    实例方法可以对当前对象的实例变量进行操作,也可以对类变量进行操作,但类方法不能访问实例变量.实例方法必须由实例对象来调用,而类方法除了可由实例对象调用外,还可以由类名直接调用. 另外,在类方法中不能使 ...

  8. shell中读写mysql数据库

    本文介绍了如何在shell中读写mysql数据库.主要介绍了如何在shell 中连接mysql数据库,如何在shell中创建数据库,创建表,插入csv文件,读取mysql数据库,导出mysql数据库为 ...

  9. phpize 动态添加 PHP 扩展的错误及解决方案

    使用phpize 动态添加 PHP 扩展是开发中经常需要做的事情,但是在 macOS 中,首次使用该功能必然会碰到一些错误,本文列出了这些错误的解决方法. 问题一: 执行 phpize 报错如下: $ ...

  10. Python代码项目目录规范v1.0

    程序目录规范:bin # 存放可执行程序 xxxx.py # 程序主程序(入口文件)config # 存放配置信息 settings.py # 全局配置文件(可能暂时未应用)db # 存放数据文件 c ...