HDU 5670 Machine 水题
Machine
题目连接:
http://acm.hdu.edu.cn/showproblem.php?pid=5670
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<263) 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
2
3 1
2 3
Sample Output
RRG
GR
Hint
题意
有一个机器,它有 \(m (2\leq m\leq 30)\) 个彩灯和一个按钮。每按下按钮时,最右边的彩灯会发生一次变换。变换为:
- 如果当前状态为红色,它将变成绿色;
2.如果当前状态为绿色,它将变成蓝色;
3.如果当前状态为蓝色,它将变成红色,并且它左边的彩灯(如果存在)也会发生一次变换。
初始状态下所有的灯都是红色的。
询问按下按钮 \(n (1\leq n< {2}^{63})\) 次以后各个彩灯的颜色。
题解:
其实就是三进制啦
代码
#include<bits/stdc++.h>
using namespace std;
int a[102];
void solve()
{
int m;long long n;
scanf("%d%lld",&m,&n);
for(int i=0;i<m;i++)
{
a[i]=n%3;
n/=3;
}
for(int i=m-1;i>=0;i--)
if(a[i]==0)printf("R");
else if(a[i]==1)printf("G");
else printf("B");
printf("\n");
}
int main()
{
int t;
scanf("%d",&t);
while(t--)solve();
return 0;
}
HDU 5670 Machine 水题的更多相关文章
- hdu 5210 delete 水题
Delete Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5210 D ...
- hdu 1251 (Trie水题)
统计难题 Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 131070/65535 K (Java/Others)Total Submi ...
- HDU 5703 Desert 水题 找规律
已知有n个单位的水,问有几种方式把这些水喝完,每天至少喝1个单位的水,而且每天喝的水的单位为整数.看上去挺复杂要跑循环,但其实上,列举几种情况之后就会发现是找规律的题了= =都是2的n-1次方,而且这 ...
- HDU 4493 Tutor 水题的收获。。
题目: http://acm.hdu.edu.cn/showproblem.php?pid=4493 题意我都不好意思说,就是求12个数的平均数... 但是之所以发博客,显然有值得发的... 这个题最 ...
- hdu 4802 GPA 水题
GPA Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=4802 Des ...
- HDU 5670 Machine
Machine Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Sub ...
- hdu 4493 Tutor 水题
Tutor Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=4493 D ...
- hdu 5495 LCS 水题
LCS Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5495 Descr ...
- hdu 4891 模拟水题
http://acm.hdu.edu.cn/showproblem.php?pid=4891 给出一个文本,问说有多少种理解方式. 1. $$中间的,(s1+1) * (s2+1) * ...*(sn ...
随机推荐
- javascript经典小游戏代码集合
http://www.jb51.net/Special/349.htm
- 树莓派开发系列教程2--树莓派3B介绍及系统烧写、基本配置
注意:树莓派系列的3篇文章里面的图片因为博客转移过程丢失了,非常抱歉 前言 树莓派系列里涉及到需要额外电脑来协助处理的部分(如烧写系统,远程访问等等),统一在运行着Ubuntu15系统的mac air ...
- python操作adb代码
adb命令的练习 #!/usr/bin/env python # encoding: utf-8 import os import re nameplt=re.compile("packag ...
- samba中的pdbedit用法
pdbedit用于在samba服务器中创建用户: 它的用法包括 pdbedit -a username:新建Samba账户. pdbedit -x username:删除Samba账户. pdbedi ...
- redis aof文件过大问题
http://www.itnose.net/detail/6682725.html 最近新安装了一台redis,版本为redis-3.2.5 数据盘用的是固态硬盘. 之前用的是普通硬盘,redis日志 ...
- 修改TortoiseSVN客户端登陆用户
TortoiseSVN是一款常用且非常不错的SVN工具,俗称小乌龟.开发的时候,经常用的当然是TortoiseSVN客户端了. 一般情况下,TortoiseSVN服务器提供的IP地址和用户都不会变,而 ...
- javascript初步了解
0.1 <script> 和 </script> 会告诉 JavaScript 在何处开始和结束. <script> 和 </script> 之间的 ...
- NTP路由器配置
14.1. 路由器日志显示时间戳 提问 在路由器 的日志和排错信息里面显示时间 回答 Router#configure terminal Enter configuration commands, o ...
- 基于AQS实现的Java并发工具类
本文主要介绍一下基于AQS实现的Java并发工具类的作用,然后简单谈一下该工具类的实现原理.其实都是AQS的相关知识,只不过在AQS上包装了一下而已.本文也是基于您在有AQS的相关知识基础上,进行讲解 ...
- Android学习笔记(三) UI布局
每一个布局都有其适合的方式,另外,这几个布局元素可以相互嵌套应用,做出美观的界面. 一.线性布局(LinearLayout) 线性布局,这个东西,从外框上可以理解为一个div,他首先是一个一个从上往下 ...