PAT 甲级 1027 Colors in Mars
https://pintia.cn/problem-sets/994805342720868352/problems/994805470349344768
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
- 代码:
- #include <bits/stdc++.h>
- using namespace std;
- const int maxn = 1e5 + 10;
- char s[maxn];
- char a[15] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C'};
- void num(int n) {
- int cnt = 0;
- if(n == 0) printf("00");
- else {
- while(n != 0) {
- s[cnt ++] = a[n % 13];
- n /= 13;
- }
- if(cnt == 1)
- printf("0%s", s);
- else {
- for(int i = cnt - 1; i >= 0; i --)
- printf("%c", s[i]);
- }
- }
- }
- int main() {
- int x, y, z;
- scanf("%d%d%d", &x, &y, &z);
- printf("#");
- num(x);
- num(y);
- num(z);
- printf("\n");
- return 0;
- }
PAT 甲级 1027 Colors in Mars的更多相关文章
- 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 ...
- PAT甲级——1027 Colors in Mars
1027 Colors in Mars People in Mars represent the colors in their computers in a similar way as the E ...
- PAT Advanced 1027 Colors in Mars (20 分)
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 (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
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 ...
- 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 ...
随机推荐
- Linux--ps及top、ls命令
day8 ps系统管理命令 ps是强大的后台进程检测命令 格式:ps [options] [--help] 选项参数: 1.-a :显示所有进程,包括PID等,包括其他用户运行的程序 2.-ef:显 ...
- windows系统下系统变量path误删恢复方法
每台计算机安装程序不同,环境变量path会有不同,若误删了环境变量path,可以如下完美解决. Win+R 输入regedit打开注册表(开始-运行里输入regedit) 找到 HKEY_LOC ...
- Python之路(四)--->list、元组、字典
好久没有更新了,感觉自己写的东西并没有太多人看,可能是因为写的不好,也可能是太基础了.学习是一个漫长的过程,结果结果固然重要,但是更重要的是在学习的过程中所学到方法,这些方法在以后的生活还是工作中都能 ...
- 批量删除C#注释
批量删除C#注释(适用于vs开发环境) 方法: 第一步:使用Ctrl+H快捷键,打开查询替换窗口 第二步:在‘查找选项’中,勾选‘使用’‘正则表达式’ 第三步:在‘查找内容’中,填写正则表达式[\t] ...
- Linux入门第二天——基本命令入门(中)
一.文件搜索命令 1.文件搜索命令:locate 速度很快(具体见Linux工具网址的对比),注意无法找到新建的文件(原理暂不展开) locate命令其实是“find -name”的另一种写法,但是要 ...
- # 第二周c实践所遇见的问题
第二周c实践所遇见的问题 地址符 在编程练习中时常忘记写入地址符,造成过运行错误,运行结果错误的惨痛教训,一个小小的错误耗费了很长的时间来寻找错误之处,养成写代码的一些好习惯势在必行.牢记scanf( ...
- Android开发——你真的了解Dialog、Toast和Snackbar吗
0. 前言 今天给大家带来一篇简单易懂的关于Android提醒小功能的文章.Dialog和Toast我们都不陌生,而Snackbar是Design Support库中提供的新控件,有些朋友可能还不了解 ...
- 一个web应用的诞生(4)--数据存储
上一章实现了登录的部分功能,之所以说是部分功能,是因为用户名和密码写成固定值肯定是不可以的,一个整体的功能,至少需要注册,登录,密码修改等,这就需要提供一个把这些值存储到数据库的能力. 当前的主流数据 ...
- 在 Symfony Command中自定义脚本把Excel数据导入到数据库中
// 注:只是在此做下记录,有兴趣的可以参考,不做实际教程文档 <?php/** * Created by IntelliJ IDEA. * User: davis * Date: 2019-0 ...
- 理解学习Springboot(一)
Springboot有何优势呢,网上一大推,这里就不写了. 一.配置maven 1.在maven官网下载maven,http://maven.apache.org/download.cgi 2.将下载 ...