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 ...
随机推荐
- test命令详解
test命令格式: test condition 通常,在if-then-else语句中,用[]代替,即[ condition ].注意:方括号两边都要用空格. 1.数值比较 ========== ...
- saprk2 structed streaming
netcat (windows) >nc -L -p 9999 import java.sql.Timestamp import org.apache.spark.sql.SparkSessio ...
- oracle 11g Enterprise Manager配置失败
Enterprise Manager以下简称em,Database Configuration Assistant简称DBCA. 病症 监听程序未启动或数据库服务未注册到该监听程序.启动该监听程序并注 ...
- ServiceBase.OnStart 方法
msdn 解释 派生类中实现时,在由服务控制管理器 (SCM) 或在操作系统启动时 (对于自动启动的服务) 时,将启动命令发送到服务时执行. 指定当服务启动时要执行的操作. 命名空间: Syste ...
- Asp.Net Mvc ScriptBundle 脚本文件捆绑压缩 导致 脚本出错的问题
由于捆绑压缩会对所有包含的文件进行压缩,无法设置忽略对某个js文件的压缩.导致压缩该js后,脚本出错的问题. 解决方式: 重写 ScriptBundle 的 GenerateBundleRespons ...
- Net Core SignalR 测试,可以用于unity、Layair、白鹭引擎、大数据分析平台等高可用消息实时通信器。
SignalR介绍 SignalR介绍来源于微软文档,不过多解释.https://docs.microsoft.com/zh-cn/aspnet/core/signalr/introduction?v ...
- dotNet core 应用部署centos
---恢复内容开始--- 阅读目录 需要安装的插件以及支撑架构 安装dotnetSDK 安装jexus 安装supervisord 遇到问题汇总 注意事项.扩展延伸 需要安装的插件以及支撑架构 1.d ...
- MahApps.Metro扁平化UI控件库(可修改主题色等)
一.名词解释 使用MahApps.Metro扁平化UI控件库,可以使界面呈现更加美观.本文将总结MahApps.Metro的使用方法,及如何自定义修改其主题颜色等. 详细内容可参考官网:https:/ ...
- 错误:Parameter '0' not found.Available parameters are [arg1, arg0, param1, param2]的解决方法
调用的方法: List<Card> temp = cardService.queryRepeat(Type,shop); xml: <select id="queryRep ...
- jzoj5347
tj:80pts:維護f[i][j]表示當前第i個方塊必須選,且選了j個的最優解,設w[i]為第i個方塊長度 則可以枚舉上次選了第k個方塊,則f[i][j]=max{f[k][j-1]+w[i]*(i ...