HDU 5670
Machine
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 163 Accepted Submission(s): 99
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?
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)
.
R indicates red. G indicates green. B indicates blue.
3 1
2 3
GR
1. 如果当前状态为红色,它将变成绿色;
2.如果当前状态为绿色,它将变成蓝色;
3.如果当前状态为蓝色,它将变成红色,并且它左边的彩灯(如果存在)也会发生一次变换。
初始状态下所有的灯都是红色的。
询问按下按钮 n(1≤n<263)n (1\leq n< {2}^{63})n(1≤n<263) 次以后各个彩灯的颜色。
#include<iostream>
#include<cstring>
#include<cstdio>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<algorithm>
#define ll __int64
#define pi acos(-1.0)
#define mod 1
#define maxn 10000
using namespace std;
int t;
map<int,char> mp;
ll n;
int m;
int b[];
int main()
{
mp[]='R';
mp[]='G';
mp[]='B';
scanf("%d",&t);
for(int i=;i<=t;i++)
{
scanf("%d %I64d",&m,&n);
int k=;
for(int j=;j<=;j++)
b[j]=;
ll exm=;
for(int i=;i<=m;i++)
exm*=;
if(n>=exm)
n=n%exm;
while(n)
{
b[k]=n%;
n/=;
k++;
}
if(k<m)
{ for(int j=m;j>k;j--)
cout<<"R";
for(int j=k-;j>=;j--)
printf("%c",mp[b[j]]);
}
else
{
for(int j=k-;j>=k-m;j--)
printf("%c",mp[b[j]]);
}
cout<<endl;
}
return ;
}
HDU 5670的更多相关文章
- HDU 5670 Machine 水题
Machine 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5670 Description There is a machine with m(2 ...
- HDU 5670 Machine
Machine Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Sub ...
- HDOJ 2111. Saving HDU 贪心 结构体排序
Saving HDU Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total ...
- 【HDU 3037】Saving Beans Lucas定理模板
http://acm.hdu.edu.cn/showproblem.php?pid=3037 Lucas定理模板. 现在才写,noip滚粗前兆QAQ #include<cstdio> #i ...
- hdu 4859 海岸线 Bestcoder Round 1
http://acm.hdu.edu.cn/showproblem.php?pid=4859 题目大意: 在一个矩形周围都是海,这个矩形中有陆地,深海和浅海.浅海是可以填成陆地的. 求最多有多少条方格 ...
- HDU 4569 Special equations(取模)
Special equations Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u S ...
- HDU 4006The kth great number(K大数 +小顶堆)
The kth great number Time Limit:1000MS Memory Limit:65768KB 64bit IO Format:%I64d & %I64 ...
- HDU 1796How many integers can you find(容斥原理)
How many integers can you find Time Limit:5000MS Memory Limit:32768KB 64bit IO Format:%I64d ...
- hdu 4481 Time travel(高斯求期望)(转)
(转)http://blog.csdn.net/u013081425/article/details/39240021 http://acm.hdu.edu.cn/showproblem.php?pi ...
随机推荐
- Big Truck
Photo by Phil Whitehouse Your boss has hired you to drive a big truck, transporting items between tw ...
- bootstrap重新设计checkbox样式
文章采集于: https://www.cnblogs.com/GumpYan/p/7845445.html#undefined 在原文基础上修改了勾勾的内容,直接采用bootstrap字体库.修改了横 ...
- 1511: [POI2006]OKR-Periods of Words
1511: [POI2006]OKR-Periods of Words https://www.lydsy.com/JudgeOnline/problem.php?id=1511 题意: 对于一个串的 ...
- centos下搭建svn服务器端/客户端
1.安装 yum install subversion httpd mod_dav_svn 2.创建仓库存储代码 mkdir /var/repos svnadmin create /var/repos ...
- DSP28335的XINTF操作SRAM实验
1. 本次使用三兄弟的XDS28335开发板,研究一下XINTF操作SRAM的代码.哈弗结构,奇怪,DSP28335是哈弗结构,那么数据和程序空间应该独立的,为啥书上说采用统一的寻址方式?估计只是读写 ...
- ubuntu 关闭触控板
第一种: 1 sudo rmmod psmouse 这个是禁用的 2 sudo modprobe psmouse 这个是启用的 这个方法很便捷,但是会将触点和触板都禁用了,一般还是希望保持触点是 ...
- Eclipse中JS文件红叉处理
使用新版本的Eclipse 或者 MyEclipse,项目中的 JS文件出现红叉,让人觉得项目中存在错误代码,给人的感觉很不爽. 记录一下去掉红叉的方法: 第1步: 打开工作空间中的项目找到项目的 . ...
- vue之vue-cookies使用
一.安装vue-cookies npm install --save vue-cookies 或者 yarn add vue-cookies 二.引入vue-cookie // 方式一:require ...
- you need to resolve your current index first 已解决
从一个分支A切换到另一个分支B后,对切换后的B分支进行pull操作,因为pull操作实际上包含了fetch+merge操作,在执行 merge操作时,由于很长时间没有对B分支执行过pull/merge ...
- TTY锁屏与解锁
今天在tmux中使用vim时,不小心按了CTRL+S,结果整个vim不能使用了,在网上查到这里会有锁屏的问题,具体如下: 在tmux中,按CTRL+S,锁屏,按CTRL+Q,解锁.与系统的锁屏和解锁是 ...