PAT1027
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
就是,一种颜色用6位数字表示,前两位表示红色,中间两位表示绿色,最后两位表示蓝色。
Blue. The only difference is that they use radix 13 (0-9 and A-C) instead of 16.
只有一点不同就是在,他们使用的是13进制取代了我们的16进制。
Now given a color in three decimal numbers (each between 0 and 168), you are supposed to output their Mars RGB values.
现在给出一个颜色的三个十进制数。每个数字从0-168,你需要输出他们的火星RGB值。
Input
Each input file contains one test case which occupies a line containing the three decimal color values.
输入案例:每个输入文件包含一个测试案例,包含一行,3个十进制颜色值。
Output
For each test case you should output the Mars RGB value in the following format:
对于每一个输出样例,你应该输出一个火星的RGB值,并符合以下的形式:
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.
先输出一个“#”,然后接着输出6位数字,所有的英文字符必须大写。如果只有一个颜色只有一个数字,必须左边加0表示。
Sample Input
15 43 71
Sample Output
#123456
#include<cstdio> #include<cstdlib> #include<iostream> #include<algorithm> using namespace std; char a[20]={ '0','1','2','3','4','5','6','7','8','9','A','B','C' }; int main() { int r,g,b; cin>>r>>g>>b; cout<<"#"<<a[r/13]<<a[r%13]<<a[g/13]<<a[g%13]<<a[b/13]<<a[b%13]<<endl; return 0; }
代码简练一些,我觉得这样已经可以算是简练了,很简单的一道题目,学习一下英语吧
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· go语言实现终端里的倒计时
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· 周边上新:园子的第一款马克杯温暖上架
· Open-Sora 2.0 重磅开源!
· 分享 3 个 .NET 开源的文件压缩处理库,助力快速实现文件压缩解压功能!
· Ollama——大语言模型本地部署的极速利器
· DeepSeek如何颠覆传统软件测试?测试工程师会被淘汰吗?