A1027 Colors in Mars (20)(20 分)
A1027 Colors in Mars (20)(20 分)
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
Each input file contains one test case which occupies a line containing the three decimal color values.
Output
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 the left.
Sample Input
15 43 71
Sample Output
#123456
思考
给的数字范围是有限的168<\(13^2\)
AC代码
#include <stdio.h>
char radix[13] = {
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C'
};
int main() {
int r, g, b;
scanf("%d%d%d", &r, &g, &b);
printf("#");
printf("%c%c", radix[r / 13], radix[r % 13]);
printf("%c%c", radix[g / 13], radix[g % 13]);
printf("%c%c", radix[b / 13], radix[b % 13]);
return 0;
}
A1027 Colors in Mars (20)(20 分)的更多相关文章
- 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 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 A1027 Colors in Mars (20)
AC代码 #include <cstdio> const int max_n = 1000; int ans[max_n]; char result[max_n]; char radix[ ...
- A1027. Colors in Mars
People in Mars represent the colors in their computers in a similar way as the Earth people. That is ...
- PAT甲级——A1027 Colors in Mars
People in Mars represent the colors in their computers in a similar way as the Earth people. That is ...
- 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 (20 分)(简单,进制转换)
1027 Colors in Mars (20 分) People in Mars represent the colors in their computers in a similar way ...
- 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 ...
随机推荐
- 寻找jar包的方法
在项目开发中经常会遇到资源jar查找难的问题,一种使用maven ,另一种方法是: (1).使用下载地址:https://oss.sonatype.org/content/repositories/r ...
- 扔掉360:Linux下无线网卡作WiFi路由器(转薄荷开源网)
这个话题很多人感兴趣,毕竟现在是无线互联时代.手机一族到外面去,首先关心的就是有没有 WiFi.Windows 7 用户可以安装 360 的软件,把笔记本电脑配置成路由器,供手机或其他电脑上网. 在 ...
- 虚拟机安装CentOS7 Minimal、jdk和hadoop
虚拟机安装CentOS7 Minimal.jdk和hadoop Table of Contents 1. 安装版本 2. PD安装 3. vim安装和配置 4. 主机名变为bogon的解决办法 5. ...
- mac 查看python安装路径
1.terminal : input: which Python 2.terminal: input : python --->import sys ----> print sys.p ...
- System.FormatException: GUID 应包含带 4 个短划线的 32 位数(xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)。解决办法
查一下数据库的UID数据是否格式正确,如: 错误格式1: {E056BB36-D824-4106-A9C3-D8D8B9ADC1C 错误格式2: E056BB36-D824-4106-A9C3-D8D ...
- World Wind Java开发之六——解析shape文件(转)
http://blog.csdn.net/giser_whu/article/details/41647117 最近一直忙于导师项目的事情了,几天没更新了,昨天和今天研究了下WWJ解析shp文件的源代 ...
- Android(java)学习笔记85:使用SQLite的基本流程
- 避免修改Android.mk添加cpp文件路径
手工输入项目需要编译的cpp文件到Android.mk里的缺点 1)繁琐,如果cpp文件很多,简直无法忍受 2)手工输入过程中容易出现错误 3)如果cpp文件更改名称,需要修改android.mk文件 ...
- JavaScript 常用的排序算法
冒泡排序 function bubbleSort(array) { for (let i = 0; i < array.length; i++) for (let j = 0; j < a ...
- es6中的promise解读
目录 什么是promise? promise的优点 回调地狱问题 Promise的三种状态 一个简单的promise promise中的then 利用promise解决回调地狱 promise的链式 ...