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 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.
译:火星上的人们在电脑中表示颜色和地球人用相似的方式。那就是 颜色用一个6 位数表示,前 2 位表示红色,中间 2 位表示绿色,最后 2 位表示蓝色。 唯一的不同是,他们(火星人)使用 13 进制 (0-9 和 A-C) 而不是 16 进制。现在给你一个三个十进制数(在 0 - 168 之间)表示颜色,你应该输出火星上的 RGB 值。
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.
译:对于每个测试用例你应该用接下来的格式输出火星上的 RGB 值:首先输出 #
然后接着输出一个所有英文字符必须大写的 6 位数字。如果单个颜色只有 1 位数,你必须在它左边输出一个 0
。
Sample Input (样例输入):
15 43 71
Sample Output (样例输出):
#123456
The Idea:
直接干!最简单的题!!! 没有之一!!!
The Codes:
#include<bits/stdc++.h>
using namespace std ;
string str = "0123456789ABC" , ans = "#" ;
int main(){
int r , g , b ;
cin >> r >> g >> b ;
ans += str[r / 13] ; // 颜色第一位
ans += str[r % 13] ; // 颜色第二位
ans += str[g / 13] ;
ans += str[g % 13] ;
ans += str[b / 13] ;
ans += str[b % 13] ;
cout<< ans << endl ;
return 0 ;
}
PAT (Advanced Level) Practice 1027 Colors in Mars (20 分) 凌宸1642的更多相关文章
- PAT (Advanced Level) Practice 1019 General Palindromic Number (20 分) 凌宸1642
PAT (Advanced Level) Practice 1019 General Palindromic Number (20 分) 凌宸1642 题目描述: A number that will ...
- PAT (Advanced Level) Practice 1011 World Cup Betting (20 分) 凌宸1642
PAT (Advanced Level) Practice 1011 World Cup Betting (20 分) 凌宸1642 题目描述: With the 2010 FIFA World Cu ...
- PAT (Advanced Level) Practice 1005 Spell It Right (20 分) 凌宸1642
PAT (Advanced Level) Practice 1005 Spell It Right (20 分) 凌宸1642 题目描述: Given a non-negative integer N ...
- PAT (Advanced Level) Practice 1001 A+B Format (20 分) 凌宸1642
PAT (Advanced Level) Practice 1001 A+B Format (20 分) 凌宸1642 题目描述: Calculate a+b and output the sum i ...
- PAT (Advanced Level) Practice 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 (Advanced Level) Practice 1054 The Dominant Color (20 分)
Behind the scenes in the computer's memory, color is always talked about as a series of 24 bits of i ...
- PAT (Advanced Level) Practice 1019 General Palindromic Number (20 分) (进制转换,回文数)
A number that will be the same when it is written forwards or backwards is known as a Palindromic Nu ...
- PAT (Advanced Level) Practice 1005 Spell It Right (20 分) (switch)
Given a non-negative integer N, your task is to compute the sum of all the digits of N, and output e ...
- PAT (Advanced Level) Practice 1011 World Cup Betting (20 分) (找最值)
With the 2010 FIFA World Cup running, football fans the world over were becoming increasingly excite ...
随机推荐
- UI Design & App & Free Icons
UI Design & App & Free Icons icons8 https://icons8.com https://icons8.com/ouch Ouch可以帮助那些不进行 ...
- Google IO & 2019
Google IO & 2019 Google IO Recap \ https://www.techradar.com/news/google-io-2019-keynote https:/ ...
- wxPython 创建基本窗口
$ pip install wxPython import wx class MyFrame(wx.Frame): def __init__(self, parent, title): super(M ...
- NGK官方又出助力市场计划方案 1万枚VAST任性送
近期NGK官方的一系列动作,可以说是在向外界宣告:NGK2.0即将来袭,席卷加密数字货币市场.前一段时间,NGK官方宣布,NGK公链布局算力领域,打造NGK算力生态星空计划,并推出了SPC星空币.目前 ...
- SPC算力币异军突起,或将跑赢币圈全场
比特币在出现反弹以后,并没有向上突破,而是回调,目前已经跌破了35000美金.目前,整个市场都在关注着比特币的动向,毕竟,比特币的走势,关注着资本的流向.不过,也有一部分巨鲸们将目光对准了币圈的其它数 ...
- MySQL -- 内部临时表
本文转载自MySQL -- 内部临时表 UNION UNION语义:取两个子查询结果的并集,重复的行只保留一行 表初始化 CREATE TABLE t1(id INT PRIMARY KEY, a I ...
- 【转载】Win10彻底格式化磁盘防止数据恢复的技巧
转载地址 注意 要尽量删除数据,请在运行cipher /w时关闭其他所有应用程序. 1.如果你在格式化磁盘后想要防止数据被恢复, Format 命令,而现在只需在其后添加 /P 参数,即可用随机数据覆 ...
- Go 去找个对象吧
前言 我的读者中应该大部分都是 Java 从业者,不知道写 Java 这些年是否真的有找到对象? 没找到也没关系,总不能在一棵树上吊死,我们也可以来 Go 这边看看,说不定会有新发现. 开个玩笑,本文 ...
- 翻译:《实用的Python编程》02_05_Collections
目录 | 上一节 (2.4 序列) | 下一节 (2.6 列表推导式) 2.5 collections 模块 collections 模块为数据处理提供了许多有用的对象.本部分简要介绍其中的一些特性. ...
- LiteOS:SpinLock自旋锁及LockDep死锁检测
摘要:除了多核的自旋锁机制,本文会介绍下LiteOS 5.0引入的LockDep死锁检测特性. 2020年12月发布的LiteOS 5.0推出了全新的内核,支持SMP多核调度功能.想学习SMP多核调度 ...