pat 1027 Colors in Mars(20 分)
1027 Colors in Mars(20 分)
People in Mars represent the colors in their computers in a similar way as the Earth people. That is, a color is represented by a 6-digit number, where the first 2 digits are for Red
, the middle 2 digits for Green
, and the last 2 digits for Blue
. The only difference is that they use radix 13 (0-9 and A-C) instead of 16. Now given a color in three decimal numbers (each between 0 and 168), you are supposed to output their Mars RGB values.
Input Specification:
Each input file contains one test case which occupies a line containing the three decimal color values.
Output Specification:
For each test case you should output the Mars RGB value in the following format: first output #
, then followed by a 6-digit number where all the English characters must be upper-cased. If a single color is only 1-digit long, you must print a 0
to its left.
Sample Input:
15 43 71
Sample Output:
#123456
- #include <iostream>
- #include <algorithm>
- #include <cstdio>
- #include <cstring>
- #include <map>
- #include <stack>
- #include <vector>
- #include <queue>
- #include <set>
- #define LL long long
- using namespace std;
- const int MAX = ;
- void calc13(int n)
- {
- stack <char> st;
- while (n)
- {
- int temp = n % ;
- if (temp >= ) st.push('A' + temp - );
- else st.push('' + temp);
- n /= ;
- }
- int len = - st.size();
- while (len --)
- cout <<'';
- while (st.size())
- {
- cout <<st.top();
- st.pop();
- }
- }
- int main()
- {
- int a, b, c;
- // freopen("Date1.txt", "r", stdin);
- scanf("%d%d%d", &a, &b, &c);
- cout <<'#';
- calc13(a) ,calc13(b) ,calc13(c) ,
- cout <<endl;
- return ;
- }
pat 1027 Colors in Mars(20 分)的更多相关文章
- PAT (Advanced Level) Practice 1027 Colors in Mars (20 分) 凌宸1642
PAT (Advanced Level) Practice 1027 Colors in Mars (20 分) 凌宸1642 题目描述: People in Mars represent the c ...
- PAT 甲级 1027 Colors in Mars (20 分)(简单,进制转换)
1027 Colors in Mars (20 分) People in Mars represent the colors in their computers in a similar way ...
- PAT Advanced 1027 Colors in Mars (20 分)
People in Mars represent the colors in their computers in a similar way as the Earth people. That is ...
- PAT (Advanced Level) Practice 1027 Colors in Mars (20 分)
People in Mars represent the colors in their computers in a similar way as the Earth people. That is ...
- 【PAT甲级】1027 Colors in Mars (20 分)
题意: 输入三个范围为0~168的整数,将它们从十三进制转化为十进制然后前缀#输出. AAAAAccepted code: #define HAVE_STRUCT_TIMESPEC #include& ...
- 1027 Colors in Mars (20 分)
People in Mars represent the colors in their computers in a similar way as the Earth people. That is ...
- PAT 1027 Colors in Mars[简单][注意]
1027 Colors in Mars (20)(20 分) People in Mars represent the colors in their computers in a similar w ...
- PAT 1027 Colors in Mars
1027 Colors in Mars (20 分) People in Mars represent the colors in their computers in a similar way ...
- 1027. Colors in Mars (20) PAT
题目:http://pat.zju.edu.cn/contests/pat-a-practise/1027 简单题,考察十进制数和n进制数的转换和输出格式的控制. People in Mars rep ...
随机推荐
- pycharm在进行debug时不小心把console关闭了,恢复console的办法
点击下图中右边的箭头就恢复了 此时可看到console已恢复
- linux上安装newman
1. newman的安装依赖nodejs,首先安装node/npm 进入到 /usr/local目录[root@ipha-dev71- local]# cd /usr/local [root@ipha ...
- spark运行java-jar:Exception in thread "main" java.io.IOException: No FileSystem for scheme: hdfs
今天碰到的一个 spark问题,困扰好久才解决 首先我的spark集群部署使用的部署包是官方提供的 spark-1.0.2-bin-hadoop2.tgz 部署在hadoop集群上. 在运行java ...
- ASP.NET Core 使用 JWT 自定义角色/策略授权需要实现的接口
目录 ① 存储角色/用户所能访问的 API ② 实现 IAuthorizationRequirement 接口 ③ 实现 TokenValidationParameters ④ 生成 Token ⑤ ...
- linux "No space left on device" 磁盘空间解决办法
某年某月某日某时,某人在工作中设置crontab定时任务规则保存时,提示“No space left on device”,此时用df -h检查磁盘,发现还有剩余空间.请问是什么原因及如何排查?什么会 ...
- ThingJS和传统3D开发的区别
物联网3D可视化开发已经辐射到各行各业,无论车间还是消防,城市还是粮仓,亦或是地铁.科技园,物联网可视化是科技的进步,也是行业的进步.而传统的3D可视化开发实施起来并不那么乐观.如果使用ThingJS ...
- vue实现rsa加密,数字签名,md5加密等
一.使用jsencrypt进行rsa加密 原文链接:Js参数RSA加密传输,jsencrypt.js的使用 - CSDN博客 *(原文处有一个地方不对,不需要转换+,rsa已经做过base64转码了) ...
- JAVA NIO 获取udp数据报的 发送方ip
程序是通了,但是没法转发,获取不到对方ip.nio中 udp使用的是DatagramChannel ,但是SelectorKey.channel()转化之后的DatagramChannel,调用get ...
- Oracle数据库 常见的SQL题,复习
01.查询员工表所有数据,并说明使用*的缺点 select * from emp 02.查询职位(JOB)为'PRESIDENT'的员工的工资 select sal from emp where jo ...
- JSP HTML 各种 乱码 解决方法|jsp include html乱码|include 乱码|MyEclipse 中文乱码
笔者花了一整天研究这个问题 .最终解决了所有的中文乱码问题. 不用 写 过滤器,不用改 tomcat 的配置文件 笔者使用的 软件是 MyEclipse2013 professional 版 JSP ...