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 ...
随机推荐
- 前端seo基础规范
基本规范 TDK代码规范 A: 关键词,一般3~4个最好,要与当前页面内容相关(根据实际情况,不适宜过多堆积关键词): B: 杜绝不同URL的页面标题重复现象,作为搜索结果摘要的重要选择目标之一,一定 ...
- zblog删除网站后台顶部菜单中的“官方网站”链接
文件\zb_system\function\c_system_admin.php 注释或删除代码 $topmenus[] = MakeTopMenu("misc", $zbp-&g ...
- oracle最高账号sys的密码认证模式
CONNECT USERNAME/PASSWORD@SERVERNAME AS SYSDBAconnect 是指连接到username是指用户名password是指密码servername是指服务名a ...
- Oracle数据库基础--建表语法+操作
语法 1.建表 create table 表名( 列名 数据类型, …… ); 2.删除表:drop table 表名; 3.添加列:alter table 表名 add(列名 数据类型); 4.修改 ...
- OutOfMemoryError异常 和 StackOverflowError异常
OutOfMemoryError异常 StackOverflowError异常 程序计数器 无 无 Java虚拟机栈 如果虚拟机栈可扩展,扩展时无法申请到足够内存 线程请求的栈深度大于虚拟机所 ...
- C# asp.net mvc 注解验证
看代码,看注解,看懂了单词,没看懂意思. 今日只能专攻一下这项特性. 1.Remote 在看这个例子的时候 ,看了JsonResult 以及 JsonRequestBehavior.AllowGet解 ...
- C++ vector类详解
转自http://blog.csdn.net/whz_zb/article/details/6827999 vector简介 vector是STL中最常见的容器,它是一种顺序容器,支持随机访问.vec ...
- [Asp.Net] Global.asax
Global.asax.cs文件会被编译到对应的dll 但部署是还需要Global.asax文件 class Global中的方法才会在程序启动时执行
- linux命令 ——目录
开始详细系统的学习linux常用命令,坚持每天一个命令,所以这个系列为每天一个linux命令.学习的主要参考资料为: 1.<鸟哥的linux私房菜> 2.http://codingstan ...
- System.FormatException: GUID 应包含带 4 个短划线的 32 位数(xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)。解决办法
查一下数据库的UID数据是否格式正确,如: 错误格式1: {E056BB36-D824-4106-A9C3-D8D8B9ADC1C 错误格式2: E056BB36-D824-4106-A9C3-D8D ...