PAT甲级——1027 Colors in Mars
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 Specification:
Each input file contains one test case which occupies a line containing the three decimal color values.
Output Specification:
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 its left.
Sample Input:
15 43 71
Sample Output:
#123456
#include<cstdio>
#include<iostream>
using namespace std;
int main()
{
const char a[13]={'0','1','2','3','4','5','6','7','8','9','A','B','C'};
int r,g,b;
scanf("%d%d%d%",&r,&g,&b);
printf("#");
printf("%c%c",a[r/13],a[r%13]);
printf("%c%c",a[g/13],a[g%13]);
printf("%c%c",a[b/13],a[b%13]);
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
https://pintia.cn/problem-sets/994805342720868352/problems/994805470349344768 People in Mars represe ...
- 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 ...
随机推荐
- JAVA中汉字的Compare排序
当调用String.compare方法的时候,比较的是Unicode码,并不能对汉字进行准确的排序,所以汉字比较时会出现比较混乱的结果. java.text.Collator类中有一个getInsta ...
- C++ 一般模板友元关系
//一般模板友元关系 #include "stdafx.h" #include <iostream> using namespace std; template< ...
- nginx 4层代理配置
1.nginx 从1.9.0版本开始支持四层代理,但做四层代理时 编译需要添加 --with-stream模块 # ./configure --prefix=/usr/local/nginx--us ...
- MyBatis 关联查询的实现:多对多
2个实体:订单.商品,一个订单可以包含多种商品,同时一种商品可以属于多个订单,即多对多. 商品表goods_tb: 订单表order_tb: no是订单编号,user_id与用户表的id关联. 需要新 ...
- django的model字段在保存的时候做预处理怎么办?
django的model字段在保存的时候做预处理怎么办? 比如这个model: class Book(Model): publish_date = DateField() 但是在保存时,用户输入数据是 ...
- 步进电机加减速S曲线算法
一.Sigmoid 函数 1.1 Sigmoid函数原型 1.2 sigmoid函数波形: 由图形可看出在-10时已经接近于0,一般取值区间在[-5,5]. 1.3 sigmoid函数的导数 转载CS ...
- 视频课程 | 云原生下的Serverless浅谈
京东云开发者社区在3月底于北京举行了以"Cloud Native时代的应用之路与开源创新"为主题的技术沙龙,现场多位技术大咖与开发者们面对面就Cloud Native进行了深入交流 ...
- mysql自关联和多表连接查询
自关联操作 多表连接查询 inner join 内查询 left join 左查询 right join 右查询 ...
- Django1.11模型类数据库操作
django模型类数据库操作 数据库操作 添加数据 1,创建类对象,属性赋值添加 book= BookInfo(name='jack',pub_date='2010-1-1') book.save() ...
- B. Odd Sum Segments CF(分割数组)
题目地址 http://codeforces.com/contest/1196/problem/B B. Odd Sum Segments time limit per test 3 seconds ...