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的更多相关文章

  1. 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 ...

  2. PAT 1027 Colors in Mars

    1027 Colors in Mars (20 分)   People in Mars represent the colors in their computers in a similar way ...

  3. PAT 1027 Colors in Mars[简单][注意]

    1027 Colors in Mars (20)(20 分) People in Mars represent the colors in their computers in a similar w ...

  4. 1027 Colors in Mars (20 分)

    1027 Colors in Mars (20 分) People in Mars represent the colors in their computers in a similar way a ...

  5. 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 ...

  6. PAT 甲级 1027 Colors in Mars (20 分)(简单,进制转换)

    1027 Colors in Mars (20 分)   People in Mars represent the colors in their computers in a similar way ...

  7. 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 ...

  8. 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 ...

  9. 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 ...

  10. 1027. Colors in Mars (20) PAT

    题目:http://pat.zju.edu.cn/contests/pat-a-practise/1027 简单题,考察十进制数和n进制数的转换和输出格式的控制. People in Mars rep ...

随机推荐

  1. Python 学习笔记(2)

    python 引号 Python 可以使用引号( ' ).双引号( " ).三引号( ''' 或 """ ) 来表示字符串,引号的开始与结束必须是相同类型的. ...

  2. 在Windows服务中添加定时器

    创建windows服务: 在VisualStudio中用C#创建一个Windows服务,微软MSDN参考地址: http://msdn.microsoft.com/zh-cn/library/zt39 ...

  3. 打造综合性智慧城市之朔州开发区 3D 可视化

      前言 近几年,我国智慧城市建设步伐也不断加快,党中央和国务院也更加注重智慧园区的建设与发展,智慧园区建设与园区产业发展相结合,向着创新化.生态化发展,更加注重高新技术.绿色环保型等产业的发展,将管 ...

  4. CVE-2018-2628-WLS Core Components 反序列化

    漏洞参考 https://blog.csdn.net/csacs/article/details/87122472 漏洞概述:在 WebLogic 里,攻击者利用其他rmi绕过weblogic黑名单限 ...

  5. 任务队列 与 Celery概述

    一.任务队列(Task Queues) 1.1 什么是任务队列? 任务队列用于管理后台工作,通常这些后台工作必须在 HTTP请求-响应循环 之外执行. 1.2 为什么需要任务队列? 对于那些不是由客户 ...

  6. 关于win10 编辑文件时权限不足问题

    win10默认是不开启administrator账户的,所以一般是自己创建一个账户,但是此账户,可能会有些文件或文件夹,访问不了,编辑不了,这时候,只需要右键->属性->安全->编辑 ...

  7. C# 应用 - 封装类访问 Mysql 数据库

    个人经历的项目主要都是用 Postgresql 或 Oracle 数据库,本文非原创,从他处整理而来. 1. 库类 mysql.data.dll using MySql.Data.MySqlClien ...

  8. Intellij IDEA设置默认字符编码

    file---settings--editor--file encoding里面设置

  9. java注解基础入门

    前言 这篇博客主要是对java注解相关的知识进行入门级的讲解,包括**,核心内容主要体现在对java注解的理解以及如何使用.希望通过写这篇博客的过程中让自己对java注解有更深入的理解,在工作中可以巧 ...

  10. Python 详解修饰器 附带 js使用修饰器

    修饰器 功能 修饰器的主要功能是,在不改变已有代码的情况下,为某一个类,方法等扩展功能 首先看这样一段代码 def foo(): for i in range(10): print(i) foo() ...