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 ...
随机推荐
- python教程(三)·函数进阶(上)
在介绍了函数定义的方法后,再来介绍一些进阶知识 参数收集 有时候我们需要参数的数量是任意的,比如print函数的参数的数量是任意的,print函数的内部实现我们不探究,但是单单是参数数量可变这一方面实 ...
- 【8086汇编-Day2】dosbox实验环境配置及测试
我学习汇编用的是王爽的<汇编语言>第三版,书中是以8086处理器为例,是工作在实模式下的,而当下的个人电脑处理器都是工作在保护模式下的.所以需要一个虚拟的工作在实模式下的处理器,这里主要用 ...
- C# typeof() 和 GetType()区是什么
1.typeof(x)中的x,必须是具体的类名.类型名称等,不可以是变量名称. 2.GetType()方法继承自Object,所以C#中任何对象都具有GetType()方法,它的作用和typeof() ...
- texterea 水平居中
例子:<div style="width: 100%;text-align: center;"> <textarea class="xinde_msg& ...
- 移除VS解决方案和TFS服务器的关系
有时候会遇到服务器IP服务器变更,甚至TFS服务器坏了,或者将项目重新上传至新的TFS区: 可以使用notepad之类的软件打开解决方案(.sln文件),删掉类似下面的部分: GlobalSectio ...
- 【LG3242】 [HNOI2015]接水果
题面 洛谷 题解 20pts 对于\(n,P,Q\leq 3000\),暴力判断每条路径的包含关系然后排序\(kth\)即可,复杂度\(O(PQ\log P)\) 另30pts 原树为一条链. 发现对 ...
- C#:在AnyCPU模式下使用CefSharp
------------吾亦无他,唯手熟尔,谦卑若愚,好学若饥------------- 本篇博客讲述如何在AnyCPU模式下使用CefSharp 因为在某些情况下,不得不用AnyCPU,但是CefS ...
- Scala中==,eq与equals的区别
根据官方API的定义: final def ==(arg0: Any): Boolean The expression x == that is equivalent to if (x eq null ...
- python基础数据类型3
python_day_5 今日大纲: 1. dict 用大括号{} 括起来. 内部使用key:value的形式来保存数据 {'jay':'周杰伦', "jj":'林俊杰'} 注意: ...
- mnist手写数字识别(神经网络)
import numpy as np from sklearn.neural_network import MLPClassifier path = 'mnist.npz' f = np.load(p ...