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. PTPX中的report 选项

    Report的生成 report_power表示产生power report,update_power表示进行power analysis. report_power命令可以生成四种形式的report ...

  2. PDO讲解

    PDO的知识点标注在代码里 <?php //造DSN:驱动名:dbname=数据库名:host=服务器地址 $dsn="mysql:dbname=mydb;host=localhost ...

  3. 为archlinux安装mplayer

    很简单的一条命令: pacman -S mplayer 安装完之后是字符界面的,所以你还需要一个图形前端: pacman -S gnome-mplayer

  4. 使用Json.Net处理json序列化和反序列化接口或继承类

    以前一直没有怎么关注过Newtonsoft的Json.Net这个第三方的.NET Json框架,主要是我以前在开发项目的时候大多数使用的都是.NET自带的Json序列化类JavaScriptSeria ...

  5. Android开机自启动程序

    背景知识:当Android启动时,会发出一个系统广播,内容为ACTION_BOOT_COMPLETED,它的字符串常量表示为 android.intent.action.BOOT_COMPLETED. ...

  6. oracle 自定义聚合函数(MAX_O3_8HOUR_ND) 计算最大的臭氧8小时滑动平均值

    create or replace function MAX_O3_8HOUR_ND(value NUMBER) return NUMBER parallel_enable aggregate usi ...

  7. eclipse运行时编码设置

    eclipse运行时编码设置:

  8. React Native微信分享 朋友圈分享 Android/iOS 通用

    超详细React Native实现微信好友/朋友圈分享功能-Android/iOS双平台通用   2016/06/16 |  React Native技术文章 |  Sky丶清|  暂无评论 |  1 ...

  9. 《图解TCP/IP》

    MAC寻址:地址转发表:IP寻址:路由控制表. 网卡(网络接口卡),NIC. 循环复用DNS技术. 代理服务器是一种应用网关.防火墙. LLC是Logical Link Control的缩写,意为:逻 ...

  10. 收藏本网站兼容火狐IE

    <script type="text/javascript"> function AddFavorite(sURL, sTitle) {try { window.ext ...