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 ...
随机推荐
- 已知整数m,n,p,q适合(m-p)|(mn+pq)证明:(m-p)|(mq+np)(整除理论1.1.5)
已知整数m,n,p,q适合(m-p)|(mn+pq)证明:(m-p)|(mq+np) 证明: 令(mn+pq)—(mq+np) =mn-np+pq-mq =n(m-p)+q(p-m) =(n-q)(m ...
- C#代码实现把网页文件保存为mht文件
MHT叫“web单一文件”.顾名思义,就是把网页中包含得图片,CSS文件以及HTML文件全部放到一个MHT文件里面.而且浏览器可以直接读取得. 由于项目需要,需实现把指定的网页文件保存为mht文件.于 ...
- DPI与PPI
首先应该明白几个概念: 1寸=3.3333333厘米(cm)1英寸(in)=2.54厘米(cm)屏幕尺寸: 屏幕对角线的长度.电脑电视同理.LCD是由液态晶体组成的显示屏(本向不发光) 有于电脑手机显 ...
- jquery的隐藏
HTML 代码:<form> <input type="text" name="email" /> <input type=&qu ...
- 《JavaScript高级程序设计》读书笔记 ---执行环境及作用域
执行环境及作用域 执行环境(execution context,为简单起见,有时也称为“环境”)是JavaScript 中最为重要的一个概念.执行环境定义了变量或函数有权访问的其他数据,决定了它们各自 ...
- 典型的DIV+CSS布局——左中右版式
[效果] [HTML] <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Def ...
- Chapter 2 Open Book——13
"People in this town," he muttered. "Dr. Cullen is a brilliant surgeon who could prob ...
- Codeforces Round #354 (Div. 2)_Vasya and String(尺取法)
题目连接:http://codeforces.com/contest/676/problem/C 题意:一串字符串,最多改变k次,求最大的相同子串 题解:很明显直接尺取法 #include<cs ...
- DB层级
最上层: 业务层 负载均衡: LVS 代理层: DB-PROXY DB层: DB主库 DB从库 随着DB出 ...
- 这一招让 Word 帮你自动生成文件目录,也能自动更新
学生的研究报告或是公司员工的提案企划书,为了务求严明详尽,往往是洋洋洒洒数十页或甚至上百页之多,像这样大篇幅的文件,在结构上通常会划分为好几个部分,比如像论文就会区分为封面.摘要.内文章节.参考文献等 ...