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 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的更多相关文章
- PAT (Advanced Level) 1027. Colors in Mars (20)
简单题. #include<cstdio> #include<cstring> #include<cmath> #include<algorithm> ...
- PTA(Advanced Level)1044.Shopping in Mars
Shopping in Mars is quite a different experience. The Mars people pay by chained diamonds. Each diam ...
- 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 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 ...
随机推荐
- Visual Studio模板
转载自MSDN,此文仅作参考. http://msdn.microsoft.com/zh-cn/library/6db0hwky(VS.80).aspx 1. 如何导入“项目模板(Project Te ...
- [ASP.NET]uploadify简单使用讲解
背景:在用户控件中使用html 的file控件或者ASP.NET的FileUpLoad控件都无法获取到文件,于是想到听说过的uploadify uploadify官网:www.uploadify.co ...
- vs2017 xamarin新建单独UWP类库提示不兼容
One or more projects are incompatible with UAP,Version=v10.0 (win10-arm). One or more projects are i ...
- 用.net开发音频编辑软件
智能语音机器人软件免不了需要对语音流进行处理,主要包括语音的播放.录制.读取.保存.图形化展示和剪辑等功能.这方面专业的软件有Adobe Audition,为了方便用户使用,我用.net实现了上述功能 ...
- VS版本与系统不兼容问题
1.VS2012在win7 64位系统安装快结束时报出一个不兼容的错误. 2.这种情况官方给出解决方法: http://www.microsoft.com/en-us/download/details ...
- wpf控件拖动
Thumb 拖动 上代码! <Window x:Class="Thumb控件移动.MainWindow" xmlns="http://schemas.microso ...
- 在MUI框架中使用video.js插件,并在暂停的时候利用Asp.net将观看时长保存到sqlserver数据库
本次保存数据的情况有三种: 在视频播放的时候点击暂停,将本视频的进度保存到数据库 利用mui内部的控件,返回上一页操作时,进行保存 安卓手机触发返回键的时候,进行保存 示例一: 在video标签上面添 ...
- JQuery Mobile - 解决切换页面时,闪屏,白屏等问题
在点击链接,切换页面时候,总是闪屏,感觉很别扭,看起来不舒服,怎么解决这个问题?方法很简单,就是在每个页面的meta标签内定义user-scalable的属性为 no! <meta name=& ...
- Ubuntu16.04 - 安装Courier New字体
这应该是一个很简单的任务吧?网上很多地方告诉我们,只要在shell终端里面执行命令:"sudo apt-get installttf-mscorefonts-installer"就 ...
- BZOJ 1003--[ZJOI2006]物流运输(最短路)
1003: [ZJOI2006]物流运输 Time Limit: 10 Sec Memory Limit: 162 MBSubmit: 10034 Solved: 4403 Description ...