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[]={
'','','','','','','','','','','A','B','C'
}; int main()
{
int r,g,b;
cin>>r>>g>>b;
cout<<"#"<<a[r/]<<a[r%]<<a[g/]<<a[g%]<<a[b/]<<a[b%]<<endl;
return ;
}
代码简练一些,我觉得这样已经可以算是简练了,很简单的一道题目,学习一下英语吧
PAT1027的更多相关文章
- PAT1027:Colors In Mars
1027. Colors in Mars (20) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue People ...
- PAT1027. Colors in Mars (20)
#include <iostream> using namespace std; string tbl="0123456789ABC"; int main() { in ...
- PAT1027 Colors in Mars (20分) 10进制转13进制
题目 People in Mars represent the colors in their computers in a similar way as the Earth people. That ...
随机推荐
- C#第六天
字符串的处理练习: 课上练习1:接收用户输入的字符串,将其中的字符以与输入相反的顺序输出."abc"→"cba" 方法1: string str = " ...
- robotframework代码定位感悟
robotframework代码定位感悟: 在做自动化的时候,有时候还是要考虑真实的操作,考虑人为反应,网络,页面渲染,服务器处理请求的过程及数据是否真实到达响应的位置, 不能一味的按照程序的速度 去 ...
- 请教下关于CKEditor富文本编辑框设置字体颜色的问题
CKEDITOR.editorConfig = function( config ){ config.plugins = 'about,a11yhelp,basicstyles,bidi,blockq ...
- js事件冒泡和捕捉
(1)冒泡型事件:事件按照从最特定的事件目标到最不特定的事件目标(document对象)的顺序触发. IE 5.5: div -> body -> document IE 6.0: div ...
- Windows下QT4.8.4编译环境的搭建(转载http://blog.csdn.net/bestgonghuibin/article/details/38933141)
开始使用QT了,所以第一步就是把环境搭起来,这里小记一下,以免以后忘记. 1. 下载安装文件 要使用QT功能,那么必须要下载QT的源码,还必须要一个是用QT的编译环境,可以是VS2010,也可以是专用 ...
- 向.net后端发送请求获取数据,在前端动态填充表格
实现效果 实现步骤 通过Ajax请求的方式 1.在前端定义Table 2.通过Ajax向.net后端发送数据请求 3.在.net后端定义方法供前端调用,并返回所需的数据 4.通过构造字符串的方式,将后 ...
- chrome插件:打开新tab时自动打开百度
下载 安装: 解压到某一目录 如要修改自动跳转链接:修改go.js中的url (function (){ chrome.tabs.getCurrent(function(tab){ chrome.ta ...
- ios随机数
ios 随机数生成 字数612 阅读3037 评论1 喜欢15 最近一直使用随机数,为了以后方便查阅,总结一下: 在C中提供了rand().srand().random().arc4random()几 ...
- hdu_2110_Crisis of HDU(母函数)
题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=2110 题意:给你N个价值和数目,求方案数,很裸的母函数. #include<cstdio> ...
- ArrayList implementation
check here. tip: 当使用remove方法时,index后边的元素要自动前移.Nothing special.