1027 Colors in Mars
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
题意:
给出三个数字将十进制数转化为13进制数字。
思路:
模拟。
Code:
1 #include <bits/stdc++.h>
2
3 using namespace std;
4
5 int main() {
6 int red, green, blue;
7 cin >> red >> green >> blue;
8 map<int, char> m;
9 m[10] = 'A';
10 m[11] = 'B';
11 m[12] = 'C';
12 string ans = "#";
13 int x1 = red / 13;
14 if (x1 < 10)
15 ans += to_string(x1);
16 else
17 ans += m[x1];
18 int x2 = red % 13;
19 if (x2 < 10)
20 ans += to_string(x2);
21 else
22 ans += m[x2];
23 int y1 = green / 13;
24 if (y1 < 10)
25 ans += to_string(y1);
26 else
27 ans += m[y1];
28 int y2 = green % 13;
29 if (y2 < 10)
30 ans += to_string(y2);
31 else
32 ans += m[y2];
33 int z1 = blue / 13;
34 if (z1 < 10)
35 ans += to_string(z1);
36 else
37 ans += m[z1];
38 int z2 = blue % 13;
39 if (z2 < 10)
40 ans += to_string(z2);
41 else
42 ans += m[z2];
43 cout << ans << endl;
44 return 0;
45 }
1027 Colors in Mars的更多相关文章
- PAT 甲级 1027 Colors in Mars (20 分)
1027 Colors in Mars (20 分) People in Mars represent the colors in their computers in a similar way a ...
- PAT 1027 Colors in Mars
1027 Colors in Mars (20 分) People in Mars represent the colors in their computers in a similar way ...
- PAT 1027 Colors in Mars[简单][注意]
1027 Colors in Mars (20)(20 分) People in Mars represent the colors in their computers in a similar w ...
- 1027 Colors in Mars (20 分)
1027 Colors in Mars (20 分) People in Mars represent the colors in their computers in a similar way a ...
- 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 ...
- 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甲级——1027 Colors in Mars
1027 Colors in Mars People in Mars represent the colors in their computers in a similar way as the E ...
- 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 ...
- PTA (Advanced Level) 1027 Colors in Mars
Colors in Mars People in Mars represent the colors in their computers in a similar way as the Earth ...
- 1027. Colors in Mars (20) PAT
题目:http://pat.zju.edu.cn/contests/pat-a-practise/1027 简单题,考察十进制数和n进制数的转换和输出格式的控制. People in Mars rep ...
随机推荐
- 前端问题录——在导入模块时使用'@'时提示"Modile is not installed"
前情提要 为了尽可能解决引用其他模块时路径过长的问题,通常会在 vue.config.js 文件中为 src 目录配置一个别名 '@' configureWebpack: { resolve: { a ...
- redis数据结构和对象二
跳跃表(skiplist) 跳跃表是一种有序数据结构.跳跃表支持平均O(logN),最坏O(N)复杂度的节点查找,大部分情况下,跳跃表的效率可以和平衡树相媲美,并且因为跳跃表的实现比平衡树简单,所有不 ...
- 一文了解python的 @property
参考自: https://www.programiz.com/python-programming/property Python为我们提供了一个内置装饰器@property,此方法使得getter和 ...
- [个人总结]pip安装tensorboard太慢
在执行pip install语句的时候直接指定国内豆瓣的镜像源进行下载: pip install -i https://pypi.douban.com/simple 你想下载的包的名称 例如下载ten ...
- crontab任务重复执行?不执行?不按照配置执行?大概率是配置出错了!!!
在使用crontab配置定时任务是,容易大意出错的配置记录,有温度的文章分享,有态度的日常记录- 一.情景1 设置每天凌晨执行某一任务,结果发现凌晨0点没分钟都执行了一次,我的天!!! 1.分析原因可 ...
- SHELL编程入门简介
一.SHELL软件概念和应用场景 1) 学习Linux技术,不是为了学习系统安装.命令操作.用户权限.配置IP.网络管理,学习Linux技术重点:基于Linux系统部署和维护各种应用软件.程序(Apa ...
- JavaScript offset、client、scroll家族
offsetParent <!DOCTYPE html> <html> <head> <meta charset="utf-8"> ...
- .NET 6 Preview 2 发布
前言 在 2021 年 3 月 11 日, .NET 6 Preview 2 发布,这次的改进主要涉及到 MAUI.新的基础库和运行时.JIT 改进. .NET 6 正式版将会在 2021 年 11 ...
- [SNOI2019] 通信
一.题目 点此看题 二.解法 一看就是傻逼补流模型,不会真的有人这个图都建不出来吧 别走啊,我不阴阳怪气了,如果你不知道怎么建这里有图嘛(思路来源是餐巾计划问题): 其中标红的边数量级很大,因为 \( ...
- Python深入:setuptools进阶
作者:gqtcgq 来源:CSDN 原文:https://blog.csdn.net/gqtcgq/article/details/49519685 Setuptools是Python Distuti ...