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. Go语言反射之反射调用

    ## 1 概述利用反射,不仅可以获取信息,还可以创建实例,执行函数和方法.就是反射代理执行. <!-- more -->## 2 创建实例创建实例的前提是具有 `reflect.Type` ...

  2. C语言中while语句里使用scanf的技巧

    今天友人和我讨论了一段代码,是HDU的OJ上一道题目的解,代码如下 #include<stdio.h> { int a,b; while(~scanf("%d%d",& ...

  3. 2015521 实验四 Android程序设计

    <JAVA程序设计> 20155214 实验四 Android程序设计 实验内容 基于Android Studio开发简单的Android应用并部署测试; 了解Android.组件.布局管 ...

  4. 20155218 2006-2007-2 《Java程序设计》第一周学习总结

    20155218 2006-2007-2 <Java程序设计>第1周学习总结 教材学习内容总结 浏览教材每章提出一个问题 组建如何与容器互动 PATH与classpath的对比 java的 ...

  5. 20155317 2016-2017-2 《Java程序设计》实验一 Java开发环境的熟悉

    20155317 2016-2017-2 <Java程序设计>实验一 Java开发环境的熟悉 实验内容 使用JDK编译.运行简单的Java程序: 使用IDEA 编辑.编译.运行.调试Jav ...

  6. day 11 名片管理系统

    1 思路 #名片1 名片2 {"name":"alex","age":18,"QQ":12123} {"nam ...

  7. Azkaban系统的安装和分析。

    Azkaban系统是一个数据处理的很好用的工具,可以用来运行hadoop任务,管理hdfs,可以进行schedule任务调度,总体来说功能还是很强大的. 研究了一下azkaban,做了以下总结性的东西 ...

  8. 解决老项目中 Timer运行一段时间后失效的问题

    那是因为Timer中的代码出现了异常未被捕获,所以线程被挂起 只需要加入  try catch即可 推荐使用 Quartz 2018-08-08 03:50:44 [ Timer-1:39366015 ...

  9. Maven学习(十三)-----Maven 构建生命周期

    Maven 构建生命周期 构建生命周期是什么? 构建生命周期阶段的目标是执行顺序是一个良好定义的序列. 这里使用一个例子,一个典型的 Maven 构建生命周期是由下列顺序的阶段: 阶段 处理 描述 准 ...

  10. Tensorflow基本开发架构

    Tensorflow基本开发架构 先说句题外话, 这段时间一直研究爬虫技术,主要目的是为将来爬取训练数据做准备,同时学习python编程.这一研究才发现,python的开发资源实在是太丰富了,所有你能 ...