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

题目解析
  本题给出3个10进制数字要求转换为13进制数字并输出,根据题意我们可以得出,转化后的每一个数字都不会超过两位。

  这样我们可以将十进制数字0~12与对应13进制数字利用map建立映射。之后将每个数字对应输出即可。

 #include <bits/stdc++.h>
using namespace std;
map<int, char> radix;
void init(){ //建立十进制数与对应13进制数的映射
for(int i = ; i < ; i++)
radix[i] = i + '';
radix[] = 'A';
radix[] = 'B';
radix[] = 'C';
}
int main()
{
init();
int red, green, blue;
scanf("%d%d%d", &red, &green, &blue);
//输入三个十进制数
//输出时先输出#
cout << "#" << radix[red / ] << radix[red % ];
//输出转化后的两位数
cout << radix[green / ] << radix[green % ];
cout << radix[blue / ] << radix[blue % ] << endl;
return ;
}

PTA (Advanced Level) 1027 Colors in Mars的更多相关文章

  1. PAT (Advanced Level) 1027. Colors in Mars (20)

    简单题. #include<cstdio> #include<cstring> #include<cmath> #include<algorithm> ...

  2. PTA(Advanced Level)1044.Shopping in Mars

    Shopping in Mars is quite a different experience. The Mars people pay by chained diamonds. Each diam ...

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

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

  5. PAT 1027 Colors in Mars

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

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

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

  7. 1027 Colors in Mars (20 分)

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

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

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

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

随机推荐

  1. Oracle 在not in中使用null的问题

    http://www.linuxidc.com/Linux/2012-07/66212.htm 以前还专门小总结过一下Oracle中关于NULL的一些问题,碰巧今天在看书的过程中又看到了另外一个以前没 ...

  2. Apache Geode with Spark

    在一些特定场景,例如streamingRDD需要和历史数据进行join从而获得一些profile信息,此时形成较小的新数据RDD和很大的历史RDD的join. Spark中直接join实际上效率不高: ...

  3. Alwayson--与复制的影响

    在主副本上建立复制后,复制的事务日志读取代理(log reader)不会读取尚未同步到辅助副本的日志,因为辅助副本可能在下一时刻转化成为主副本,变为新的复制发布服务器,为此需要保证复制处理的日志总慢于 ...

  4. C# npoi 从excel导入datagridviews 批量联网核查

    DataSet ds = new DataSet(); OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.Fil ...

  5. InnoDB之锁机制

    前两天听了姜老大关于InnoDB中锁的相关培训,刚好也在看这方面的知识,就顺便利用时间把这部分知识做个整理,方便自己理解.主要分为下面几个部分 1. InnoDB同步机制 InnoDB存储引擎有两种同 ...

  6. disruptor调优方法

    翻译自disruptor在github上的文档,https://github.com/LMAX-Exchange/disruptor/wiki/Getting-Started Basic Tuning ...

  7. day 104 luffy项目第二天

    一.前端配置 二.后端配置 一.前端配置 app.vue 二 . 后端配置 model模型配置 迁移数据 序列化 views.py文件配置 url路由 配置中间件解决跨域问题 重新设计下 model模 ...

  8. 自定义控件和View

    一.自定义控件 MotionEvent.ACTION_UP:抬起 MotionEvent.ACTION_DOWN: 按下 MotionEvent.ACTION_POINTER_UP: MotionEv ...

  9. [Other] 应用下载网站的APK/IPA等常见MIME设置

    类型 扩展名 mime 错误做法 安卓安装包 .apk application/vnd.android.package-archive application/vnd.android 苹果安装包 .i ...

  10. 非常好用的@ResponseBody注解

    AJAX的写法: ajax接收json格式: ①如果ajax接收的是text dataType:"text", var json = eval("(" + da ...