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的更多相关文章

  1. 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 ...

  2. PAT 甲级 1027 Colors in Mars (20 分)(简单,进制转换)

    1027 Colors in Mars (20 分)   People in Mars represent the colors in their computers in a similar way ...

  3. 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 ...

  4. 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 ...

  5. PAT甲级——A1027 Colors in Mars

    People in Mars represent the colors in their computers in a similar way as the Earth people. That is ...

  6. 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 ...

  7. PAT 1027 Colors in Mars

    1027 Colors in Mars (20 分)   People in Mars represent the colors in their computers in a similar way ...

  8. PAT 1027 Colors in Mars[简单][注意]

    1027 Colors in Mars (20)(20 分) People in Mars represent the colors in their computers in a similar w ...

  9. 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 ...

随机推荐

  1. ImageMagick命令执行学习笔记(常见于图片预览处)

    实验版本: ImageMagick版本:6.9.2 push graphic-context viewbox 0 0 640 480 fill 'url(https://"|whoami&q ...

  2. java入门---变量类型&类变量&局部变量&实例变量&静态变量

        在Java语言中,所有的变量在使用前必须声明.声明变量的基本格式如下:     type identifier [ = value][, identifier [= value] ...] ; ...

  3. 安装虚拟机与初触linux心得

    安装虚拟机与初触linux心得 安装虚拟机 不知道是电脑问题还是软件问题,我安装虚拟机的过程异常坎坷,首先我在官网,360,太平洋等地方下载的virtualbox5.0以后的软件普遍有问题,问题是打不 ...

  4. 20155215 2016-2017-2 《Java程序设计》第4周学习总结

    20155215 2016-2017-2 <Java程序设计>第X周学习总结 教材学习内容总结 第六章 继承,避免多个类间重复定义共同行为.子类继承父类,再扩充(extends)其他行为. ...

  5. apt-get 0%

    错误如下:      www.2cto.com   使用apt-get命令安装软件时出现“0%[正在等待报头]“的提示且无法继续安装,一般出现此问题是因为安装过程中Ctrl+C强行中断或其它原因导致上 ...

  6. 《图说VR入门》——googleVR 他山之玉

    本文章由cartzhang编写,转载请注明出处. 所有权利保留. 文章链接:http://blog.csdn.net/cartzhang/article/details/53125482 作者:car ...

  7. Maven学习(十一)-----使用Maven创建Web应用程序项目

    使用Maven创建Web应用程序项目 用到的技术/工具: Maven 3.3.3 Eclipse 4.3 JDK 8 Spring 4.1.1.RELEASED Tomcat 7 Logback 1. ...

  8. Java的Graphics类进行绘图的方法详解

    Graphics类提供基本绘图方法,Graphics2D类提供更强大的绘图能力. Graphics类提供基本的几何图形绘制方法,主要有:画线段.画矩形.画圆.画带颜色的图形.画椭圆.画圆弧.画多边形等 ...

  9. 使用Python的Requests库进行web接口测试

    1.Requests简介Requests 是使用 Apache2 Licensed 许可证的 HTTP 库.用 Python 编写,真正的为人类着想. Python 标准库中的 urllib2 模块提 ...

  10. Vue 项目在其他电脑 npm run dev 运行报错的解决方法

    一个 Vue 项目从一台电脑上传到 github 上之后,再另外一台电脑上 git clone .并使用 npm run dev 或 npm run start 发生以下报错的解决方法.   报错原因 ...